Header Header

Image handling


Detailed Description

Functions for image handling.


Functions

static gxi32 gx_initimage (gxHANDLE handle, gxIMAGE *pimage)
 Initialization of an image located on the heap or stack.
static gxi32 gx_allocimage (gxHANDLE handle, gxIMAGE **pimage)
 This function allocates a blank image.
static gxi32 gx_freeimage (gxHANDLE handle, gxIMAGE *pimage)
 Frees an image structure including the allocated pixel data.
static gxi32 gx_createimage (gxHANDLE handle, gxIMAGE *pimage, gxi32 format, gxi32 xsize, gxi32 ysize, gxi32 sline)
 Makes an image with proper size and format running on an initialized image structure.
static gxi32 gx_convertimage (gxHANDLE handle, gxIMAGE *pdest, gxIMAGE *psrc, gxi32 format, gxi32 xsize, gxi32 ysize, gxi32 sline)
 Converts an image to a specific format and size.
static gxi32 gx_zoomimage (gxHANDLE handle, gxIMAGE *pdest, gxi32 xsize, gxi32 ysize, gxi32 sline, gxIMAGE *psrc, gxi32 sx1_8, gxi32 sy1_8, gxi32 sx2_8, gxi32 sy2_8)
 Zooms an image to a specified size.
static gxi32 gx_rotateimage (gxHANDLE handle, gxIMAGE *pdest, gxIMAGE *psrc, gxi32 degree)
 Rotates an image to a specified degree.
static gxi32 gx_mirrorimage (gxHANDLE handle, gxIMAGE *pdest, gxIMAGE *psrc, gxi32 flags)
 Mirrors an image to a specified mode.
static gxi32 gx_loadimage (gxHANDLE handle, gxIMAGE *pimage, const wchar_t *filename, gxi32 pixelformat)
 Loads an image from a mass storage device and converts it to a specific pixel format (Unicode version).
static gxi32 gx_loadimagea (gxHANDLE handle, gxIMAGE *pimage, const char *filename, gxi32 pixelformat)
 Loads an image from a mass storage device and converts it to a specific pixel format (ASCII version).
static gxi32 gx_saveimage (gxHANDLE handle, gxIMAGE *pimage, const wchar_t *filename, gxi32 fileformat)
 Saves an image to a mass storage device in the specific file format (Unicode version).
static gxi32 gx_saveimagea (gxHANDLE handle, gxIMAGE *pimage, const char *filename, gxi32 fileformat)
 Saves an image to a mass storage device in the specific file format (ASCII version).
static gxi32 gx_loadfrommem (gxHANDLE handle, gxIMAGE *pimage, const void *buffer, gxi32 buflen, gxi32 pixelformat)
 Loads an image from the memory and converts it to a specific pixel format.
static gxi32 gx_savetomem (gxHANDLE handle, gxIMAGE *pimage, void **buffer, gxi32 *buflen, gxi32 fileformat)
 Saves an image in a specific file format to a specific memory area.
static gxi32 gx_isvalidimage (gxHANDLE handle, const gxIMAGE *pimage)
 Checks if image structure is valid.
static gxi32 gx_copyimage (gxHANDLE handle, gxIMAGE *target, gxIMAGE *source)
 Copies an image to another.
static gxi32 gx_testimagefileformat (gxHANDLE handle, const wchar_t *filename, gxi32 *fileformat)
 Tests if a file is an image file.
static gxi32 gx_testimagefileformata (gxHANDLE handle, const char *filename, gxi32 *fileformat)
 Tests if a file is an image file.
static gxi32 gx_testimagefileformatmem (gxHANDLE handle, const void *buffer, gxi32 buflen, gxi32 *fileformat)
 Tests if a memory area contains an image file.
static gxi32 gx_testimagefileformatid (gxHANDLE handle, const wchar_t *filename, wchar_t *formatid, gxi32 slen)
 Tests if a file is an image file.
static gxi32 gx_testimagefileformatidmem (gxHANDLE handle, const void *buffer, gxi32 buflen, wchar_t *formatid, gxi32 slen)
 Tests if a memory area contains an image file.
static int gx_coloradjust (gxHANDLE imgexthandle, gxIMAGE *image, float contrast, float brightness, float saturation, float gamma, int flags)
 Makes contrast, brightness, saturation and gamma correction on the image.
static int gx_colormixer (gxHANDLE imgexthandle, gxIMAGE *target, gxIMAGE *source, int r1, int g1, int b1, int r2, int g2, int b2, int r3, int g3, int b3)
 Changes the colors of the source image based on the weight parameters.
static int gx_imagedifference (gxHANDLE imgexthandle, gxIMAGE *target, gxIMAGE *source1, gxIMAGE *source2)
 Generates a differential image from two images.
static int gx_imagetransform (gxHANDLE imgexthandle, gxIMAGE *target, gxIMAGE *source, gxPG4 area, void *bgcolor)
 Transforms a general area from the source image in the target image.
static int gx_imageftransform (gxHANDLE imgexthandle, gxIMAGE *target, gxIMAGE *source, gxTRAFO *trafo, void *bgcolor)
 Fine transforms an image with the transformation described by the trafo.
static int gx_imagecompose (gxHANDLE imgexthandle, gxIMAGE *target, gxIMAGE *upper, gxIMAGE *lower, gxPNT position, float alpha_u, float alpha_l, int flags, void *bgcolor)
 Composes two images.
static int gx_drawtext (gxHANDLE imgexthandle, gxIMAGE *image, const char *text, gxPNT position, const char *fonttype, int fontheight, int fontwidth, void *txtcolor, unsigned int flags)
 Draw text on an image.


Function Documentation

static gxi32 gx_initimage ( gxHANDLE  handle,
gxIMAGE pimage 
) [static]

Initialization of an image located on the heap or stack.

This function fills the structure identifier and the reference counter properly. The other data members are set to zero value.

Warning:
Do not call it for a dynamic allocated image (gx_allocimage)!
Parameters:
handle Handle of the module.
pimage Pointer to the not initialized image structure.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_allocimage ( gxHANDLE  handle,
gxIMAGE **  pimage 
) [static]

This function allocates a blank image.

The structure identifier and the reference counter will be properly filled. The other data members are set to zero value.

Parameters:
handle Handle of the module.
pimage Pointer to a gxIMAGE structure pointer where the function returns the pointer of the allocated image area.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_freeimage ( gxHANDLE  handle,
gxIMAGE pimage 
) [static]

Frees an image structure including the allocated pixel data.

If the value of the reference counter is not properly set the function returns an error. In case of dynamically allocated images it is advised to use gx_unrefimage.

Parameters:
handle Handle of the module.
pimage Pointer to the image structure.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_createimage ( gxHANDLE  handle,
gxIMAGE pimage,
gxi32  format,
gxi32  xsize,
gxi32  ysize,
gxi32  sline 
) [static]

Makes an image with proper size and format running on an initialized image structure.

Parameters:
handle Handle of the module.
pimage Pointer to the image structure.
format Pixel format (see GX_PIXELFORMATS).
xsize Horizontal size of image in pixels.
ysize Vertical size of image in pixels.
sline Length of a row in bytes (min.: xsize * size of a pixel in bytes). If zero the system computes the correct value.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_convertimage ( gxHANDLE  handle,
gxIMAGE pdest,
gxIMAGE psrc,
gxi32  format,
gxi32  xsize,
gxi32  ysize,
gxi32  sline 
) [static]

Converts an image to a specific format and size.

The destination image must be initialized.

Parameters:
handle Handle of the module.
pdest Pointer to an initialized image where the function places the converted image.
psrc Pointer to the source image.
format Pixel format of the destination image (see GX_PIXELFORMATS).
xsize Horizontal size of the destination image in pixels.
ysize Vertical size of the destination image in pixels.
sline Length of a row in bytes (min.: xsize * size of a pixel in bytes). If zero the system computes the correct value.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_zoomimage ( gxHANDLE  handle,
gxIMAGE pdest,
gxi32  xsize,
gxi32  ysize,
gxi32  sline,
gxIMAGE psrc,
gxi32  sx1_8,
gxi32  sy1_8,
gxi32  sx2_8,
gxi32  sy2_8 
) [static]

Zooms an image to a specified size.

Parameters:
handle Handle of the module.
pdest Pointer to an initialized image where the function places the zoomed image.
xsize Horizontal size of the destination area.
ysize Vertical size of the destination area.
sline Size of a row of the destination area.
psrc Pointer to the source image.
sx1_8 Left coordinate of the zoomed area (shifted left with 8 bit = 256)
sy1_8 Top coordinate of the zoomed area (shifted left with 8 bit = 256)
sx2_8 Right coordinate of the zoomed area (shifted left with 8 bit = 256)
sy2_8 Bottom coordinate of the zoomed area (shifted left with 8 bit = 256)
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_rotateimage ( gxHANDLE  handle,
gxIMAGE pdest,
gxIMAGE psrc,
gxi32  degree 
) [static]

Rotates an image to a specified degree.

Parameters:
handle Handle of the module.
pdest Pointer to an initialized image where the function places the zoomed image.
psrc Pointer to the source image.
degree Degree (Must be 0, 90, 180, 270).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_mirrorimage ( gxHANDLE  handle,
gxIMAGE pdest,
gxIMAGE psrc,
gxi32  flags 
) [static]

Mirrors an image to a specified mode.

Parameters:
handle Handle of the module.
pdest Pointer to an initialized image where the function places the zoomed image.
psrc Pointer to the source image.
flags Mirror flags. It can be GX_MIRROR_HORIZONTAL or/and GX_MIRROR_VERTICAL (see GX_MIRRORFLAGS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_loadimage ( gxHANDLE  handle,
gxIMAGE pimage,
const wchar_t *  filename,
gxi32  pixelformat 
) [static]

Loads an image from a mass storage device and converts it to a specific pixel format (Unicode version).

On loading a RAW image, the gxIMAGE must be created with correct parameters (sline parameter also included). The format parameter of the gx_loadimage() must be -1 for RAW images.

   gxIMAGE image;
   gx_initimage(&image);
   gx_createimage(&image, GX_GRAY, 1024, 768, 1024);
   gx_loadimage(&image, "test.raw", -1);
   ...

Parameters:
handle Handle of the module.
pimage Pointer to an initialized image structure where the function loads the data.
filename Name of the image file.
pixelformat The specific pixel format. Giving GX_GRAY converts a color image to grayscale (see GX_PIXELFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_loadimagea ( gxHANDLE  handle,
gxIMAGE pimage,
const char *  filename,
gxi32  pixelformat 
) [static]

Loads an image from a mass storage device and converts it to a specific pixel format (ASCII version).

On loading a RAW image, the gxIMAGE must be created with correct parameters (sline parameter also included). The format parameter of the gx_loadimage() must be -1 for RAW images.

   gxIMAGE image;
   gx_initimage(&image);
   gx_createimage(&image, GX_GRAY, 1024, 768, 1024);
   gx_loadimagea(&image, "test.raw", -1);
   ...

Parameters:
handle Handle of the module.
pimage Pointer to an initialized image structure where the function loads the data.
filename Name of the image file.
pixelformat The specific pixel format. Giving GX_GRAY converts a color image to grayscale (see GX_PIXELFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_saveimage ( gxHANDLE  handle,
gxIMAGE pimage,
const wchar_t *  filename,
gxi32  fileformat 
) [static]

Saves an image to a mass storage device in the specific file format (Unicode version).

Parameters:
handle Handle of the module.
pimage Pointer to the image.
filename Name of the image file.
fileformat Format of the image file (see GX_IMGFILEFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_saveimagea ( gxHANDLE  handle,
gxIMAGE pimage,
const char *  filename,
gxi32  fileformat 
) [static]

Saves an image to a mass storage device in the specific file format (ASCII version).

Parameters:
handle Handle of the module.
pimage Pointer to the image.
filename Name of the image file.
fileformat Format of the image file (see GX_IMGFILEFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_loadfrommem ( gxHANDLE  handle,
gxIMAGE pimage,
const void *  buffer,
gxi32  buflen,
gxi32  pixelformat 
) [static]

Loads an image from the memory and converts it to a specific pixel format.

On loading a RAW image, the gxIMAGE must be created with correct parameters (sline parameter also included). The format parameter of the gx_loadfrommem() must be -1 for RAW images.

Parameters:
handle Handle of the module.
pimage Pointer to an initialized image structure where the function loads the data.
buffer Pointer to the image data.
buflen Length of image data in bytes.
pixelformat The specific pixel format. Giving GX_GRAY converts a color image to grayscale (see GX_PIXELFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_savetomem ( gxHANDLE  handle,
gxIMAGE pimage,
void **  buffer,
gxi32 *  buflen,
gxi32  fileformat 
) [static]

Saves an image in a specific file format to a specific memory area.

Parameters:
handle Handle of the module.
pimage Pointer to the image.
buffer Pointer to the memory area pointer that is large enough or NULL.
buflen Size of the memory area.
fileformat Format of the image file (see GX_IMGFILEFORMATS).
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_isvalidimage ( gxHANDLE  handle,
const gxIMAGE pimage 
) [static]

Checks if image structure is valid.

Parameters:
handle Handle of the module.
pimage Pointer to the image.
Returns:
In case of valid image the return value is non-zero.

References gx_call().

static gxi32 gx_copyimage ( gxHANDLE  handle,
gxIMAGE target,
gxIMAGE source 
) [static]

Copies an image to another.

Parameters:
handle Handle of the module.
target Pointer to the initialized destination image.
source Pointer to the source image.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_testimagefileformat ( gxHANDLE  handle,
const wchar_t *  filename,
gxi32 *  fileformat 
) [static]

Tests if a file is an image file.

Parameters:
handle Handle of the module.
filename Name of the file to test.
fileformat Buffer for the fileformat. -1 is returned for unknown file type.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_testimagefileformata ( gxHANDLE  handle,
const char *  filename,
gxi32 *  fileformat 
) [static]

Tests if a file is an image file.

Parameters:
handle Handle of the module.
filename Name of the file to test.
fileformat Buffer for the fileformat. -1 is returned for unknown file type.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_testimagefileformatmem ( gxHANDLE  handle,
const void *  buffer,
gxi32  buflen,
gxi32 *  fileformat 
) [static]

Tests if a memory area contains an image file.

Parameters:
handle Handle of the module.
buffer Pointer to the memory area.
buflen Size of the memory area.
fileformat Buffer for the fileformat. -1 is returned for unknown file type.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_testimagefileformatid ( gxHANDLE  handle,
const wchar_t *  filename,
wchar_t *  formatid,
gxi32  slen 
) [static]

Tests if a file is an image file.

Parameters:
handle Handle of the module.
filename Name of the file to test.
formatid Buffer for the formatid. "" is returned for unknown file type.
slen Buffer length for formatid.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static gxi32 gx_testimagefileformatidmem ( gxHANDLE  handle,
const void *  buffer,
gxi32  buflen,
wchar_t *  formatid,
gxi32  slen 
) [static]

Tests if a memory area contains an image file.

Parameters:
handle Handle of the module.
buffer Pointer to the memory area.
buflen Size of the memory area.
formatid Buffer for the formatid. "" is returned for unknown file type.
slen Buffer length for formatid.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_coloradjust ( gxHANDLE  imgexthandle,
gxIMAGE image,
float  contrast,
float  brightness,
float  saturation,
float  gamma,
int  flags 
) [static]

Makes contrast, brightness, saturation and gamma correction on the image.

The usual values for the adjusting values are between [-1, 1], the level change calculation can be expressed by the

new_level = (1+f)*old_level 
abstraction.

The value of -1 discards all the partial information, a value of 0 does not modify the image setting.

For the gamma correction other rules are applied. The value of 1 leaves the image unchanged.

Parameters:
imgexthandle Handle to the imgext module.
image Image to process.
contrast Contrast adjust level.
brightness Brightness adjust level.
saturation Saturation adjust level.
gamma Gamma correction level.
flags Color adjusting flags, see GX_COLORADJUST_FLAGS.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_colormixer ( gxHANDLE  imgexthandle,
gxIMAGE target,
gxIMAGE source,
int  r1,
int  g1,
int  b1,
int  r2,
int  g2,
int  b2,
int  r3,
int  g3,
int  b3 
) [static]

Changes the colors of the source image based on the weight parameters.

This function is an advanced image manipulating function that can be used in adaptive processes by setting the weights.

Note:
If only the first three weights are defined the resulted image will be a grayscale image.
Parameters:
imgexthandle Handle to the imgext module.
target Preallocated image to return the result.
source Image to process.
r1 Adaptable weight.
g1 Adaptable weight.
b1 Adaptable weight.
r2 Adaptable weight.
g2 Adaptable weight.
b2 Adaptable weight.
r3 Adaptable weight.
g3 Adaptable weight.
b3 Adaptable weight.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_imagedifference ( gxHANDLE  imgexthandle,
gxIMAGE target,
gxIMAGE source1,
gxIMAGE source2 
) [static]

Generates a differential image from two images.

Parameters:
imgexthandle Handle to the imgext module.
target Preallocated image to return the result.
source1 First image.
source2 Second image.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_imagetransform ( gxHANDLE  imgexthandle,
gxIMAGE target,
gxIMAGE source,
gxPG4  area,
void *  bgcolor 
) [static]

Transforms a general area from the source image in the target image.

Parameters:
imgexthandle Handle to the imgext module.
target Preallocated image to return the result.
source Image to process.
area General area defined on the source image.
bgcolor Background color for filling parts that are not defined by the source image.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_imageftransform ( gxHANDLE  imgexthandle,
gxIMAGE target,
gxIMAGE source,
gxTRAFO trafo,
void *  bgcolor 
) [static]

Fine transforms an image with the transformation described by the trafo.

Parameters:
imgexthandle Handle to the imgext module.
target Preallocated image to return the result.
source Image to process.
trafo Transformation descriptor.
bgcolor Background color for filling parts that are not defined by the source image.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_imagecompose ( gxHANDLE  imgexthandle,
gxIMAGE target,
gxIMAGE upper,
gxIMAGE lower,
gxPNT  position,
float  alpha_u,
float  alpha_l,
int  flags,
void *  bgcolor 
) [static]

Composes two images.

Parameters:
imgexthandle Handle to the imgext module.
target Preallocated image to return the result.
upper Upper image.
lower Lower image.
position Position of the upper image defined on the lower image.
alpha_u Alpha channel of the upper image.
alpha_l Alpha channel of the lower image.
flags Image composing flags, see GX_COMPOSE_FLAGS.
bgcolor Background color for filling parts that are not defined by the source images.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().

static int gx_drawtext ( gxHANDLE  imgexthandle,
gxIMAGE image,
const char *  text,
gxPNT  position,
const char *  fonttype,
int  fontheight,
int  fontwidth,
void *  txtcolor,
unsigned int  flags 
) [static]

Draw text on an image.

If no image given, create a grayscale image.

Parameters:
imgexthandle Handle to the imgext module.
image Preallocated image to return the result.
text Text to draw.
position Position of the text on image.
fonttype Name of the fontface (WIN32) or path of the font file (LINUX).
fontheight Character height of the text in logical units.
fontwidth Average character width in logical units.
txtcolor Text color.
flags WIN32: see GX_TEXT_FLAGS.
Returns:
On error false is returned and the error code/string in the GX system is set appropriately ( see gx_geterror() ).

References gx_call().


Generated  for GX
(c) Adaptive Recognition