IM: imImage

IM - An Imaging Tool

imImage
[Image Representation]


Detailed Description

Base definitions and functions for image representation.
Only the image processing operations depends on these definitions, Image Storage and Image Capture are completely independent.
You can also initialize a structure with your own memory buffer, see imImageInit. To release the structure without releasing the buffer, set "data[0]" to NULL before calling imImageDestroy.
See im_image.h


Modules

 Image Conversion

Data Structures

struct  _imImage
 imImage Structure Definition. More...

Defines

#define imPutBitmap(_image, _x, _y, _w, _h, _xmin, _xmax, _ymin, _ymax)

Typedefs

typedef _imImage imImage

Functions

imImageimImageCreate (int width, int height, int color_space, int data_type)
imImageimImageInit (int width, int height, int color_space, int data_type, void *data_buffer, long *palette, int palette_count)
imImageimImageCreateBased (const imImage *image, int width, int height, int color_space, int data_type)
void imImageDestroy (imImage *image)
void imImageAddAlpha (imImage *image)
void imImageReshape (imImage *image, int width, int height)
void imImageCopy (const imImage *src_image, imImage *dst_image)
void imImageCopyData (const imImage *src_image, imImage *dst_image)
imImageimImageDuplicate (const imImage *image)
imImageimImageClone (const imImage *image)
void imImageSetAttribute (imImage *image, const char *attrib, int data_type, int count, const void *data)
const void * imImageGetAttribute (const imImage *image, const char *attrib, int *data_type, int *count)
void imImageGetAttributeList (const imImage *image, char **attrib, int *attrib_count)
void imImageClear (imImage *image)
int imImageIsBitmap (const imImage *image)
void imImageSetPalette (imImage *image, long *palette, int palette_count)
void imImageCopyAttributes (const imImage *src_image, imImage *dst_image)
int imImageMatchSize (const imImage *image1, const imImage *image2)
int imImageMatchColor (const imImage *image1, const imImage *image2)
int imImageMatchDataType (const imImage *image1, const imImage *image2)
int imImageMatchColorSpace (const imImage *image1, const imImage *image2)
int imImageMatch (const imImage *image1, const imImage *image2)
void imImageSetBinary (imImage *image)
void imImageMakeBinary (imImage *image)

Define Documentation

#define imPutBitmap _image,
_x,
_y,
_w,
_h,
_xmin,
_xmax,
_ymin,
_ymax   ) 
 

Value:

{                                                                         \
    if (_image->color_space == IM_RGB)                                      \
    {                                                                       \
      if (_image->has_alpha)                                                \
        cdPutImageRectRGBA(_image->width, _image->height,                   \
                          (unsigned char*)_image->data[0],                  \
                          (unsigned char*)_image->data[1],                  \
                          (unsigned char*)_image->data[2],                  \
                          (unsigned char*)_image->data[3],                  \
                          _x, _y, _w, _h, _xmin, _xmax, _ymin, _ymax);      \
      else                                                                  \
        cdPutImageRectRGB(_image->width, _image->height,                    \
                          (unsigned char*)_image->data[0],                  \
                          (unsigned char*)_image->data[1],                  \
                          (unsigned char*)_image->data[2],                  \
                          _x, _y, _w, _h, _xmin, _xmax, _ymin, _ymax);      \
    }                                                                       \
    else                                                                    \
      cdPutImageRectMap(_image->width, _image->height,                      \
                        (unsigned char*)_image->data[0], _image->palette,   \
                        _x, _y, _w, _h, _xmin, _xmax, _ymin, _ymax);        \
  }
Utility macro to draw the image in a CD library canvas. Works only for data_type IM_BYTE, and color spaces: IM_RGB, IM_MAP, IMGRAY and IM_BINARY.


Typedef Documentation

typedef struct _imImage imImage
 

imImage Structure Definition.

An image representation than supports all the color spaces, but planes are always unpacked and the orientation is always bottom up.


Function Documentation

imImage* imImageCreate int  width,
int  height,
int  color_space,
int  data_type
 

Creates a new image. See also imDataType and imColorSpace.

im.ImageCreate(width: number, height: number, color_space: number, data_type: number) -> image: imImage [in Lua 5] 

imImage* imImageInit int  width,
int  height,
int  color_space,
int  data_type,
void *  data_buffer,
long *  palette,
int  palette_count
 

Initializes the image structure but does not allocates image data. See also imDataType and imColorSpace.

imImage* imImageCreateBased const imImage image,
int  width,
int  height,
int  color_space,
int  data_type
 

Creates a new image based on an existing one.
If the addicional parameters are -1, the given image parameters are used.
The image atributes always are copied. See also imDataType and imColorSpace.

im.ImageCreateBased(image: imImage, [width: number], [height: number], [color_space: number], [data_type: number]) -> image: imImage [in Lua 5] 
The addicional parameters in Lua should be nil, and they can also be functions with the based image as a parameter.

void imImageDestroy imImage image  ) 
 

Destroys the image and frees the memory used. image data is destroyed only if its data[0] is not NULL.

im.ImageDestroy(image: imImage) [in Lua 5] 
image:Destroy() [in Lua 5] 

void imImageAddAlpha imImage image  ) 
 

Adds an alpha channel plane.

image:AddAlpha() [in Lua 5] 

void imImageReshape imImage image,
int  width,
int  height
 

Changes the buffer size. Reallocate internal buffers if the new size is larger than the original.

image:Reshape(width: number, height: number) [in Lua 5] 

void imImageCopy const imImage src_image,
imImage dst_image
 

Copy image data and attributes from one image to another.
Images must have the same size and type.

image:Copy(dst_image: imImage) [in Lua 5] 

void imImageCopyData const imImage src_image,
imImage dst_image
 

Copy image data only fom one image to another.
Images must have the same size and type.

image:CopyData(dst_image: imImage) [in Lua 5] 

imImage* imImageDuplicate const imImage image  ) 
 

Creates a copy of the image.

image:Duplicate() -> new_image: imImage [in Lua 5] 

imImage* imImageClone const imImage image  ) 
 

Creates a clone of the image. i.e. same attributes but ignore contents.

image:Clone() -> new_image: imImage [in Lua 5] 

void imImageSetAttribute imImage image,
const char *  attrib,
int  data_type,
int  count,
const void *  data
 

Changes an extended attribute.
The data will be internally duplicated.
If data is NULL the attribute is removed.
If count is -1 and data_type is IM_BYTE then data is zero terminated. See also imDataType.

image:SetAttribute(attrib: string, data_type: number, data: table of numbers or string) [in Lua 5] 
If data_type is IM_BYTE, as_string can be used as data.

const void* imImageGetAttribute const imImage image,
const char *  attrib,
int *  data_type,
int *  count
 

Returns an extended attribute.
Returns NULL if not found. See also imDataType.

image:GetAttribute(attrib: string, [as_string: boolean]) -> data: table of numbers or string, data_type: number [in Lua 5] 
If data_type is IM_BYTE, as_string can be used to return a string instead of a table.

void imImageGetAttributeList const imImage image,
char **  attrib,
int *  attrib_count
 

Returns a list of the attribute names.
"attrib" must contain room enough for "attrib_count" names. Use "attrib=NULL" to return only the count.

image:GetAttributeList() -> data: table of strings [in Lua 5] 

void imImageClear imImage image  ) 
 

Sets all image data to zero.

image:Clear() [in Lua 5] 

int imImageIsBitmap const imImage image  ) 
 

Indicates that the image can be viewed in common graphic devices. Data type must be IM_BYTE. Color mode can be IM_RGB, IM_MAP, IM_GRAY or IM_BINARY.

image:IsBitmap() -> is_bitmap: boolean [in Lua 5] 

void imImageSetPalette imImage image,
long *  palette,
int  palette_count
 

Changes the image palette. This will destroy the existing palette and replace it with the given palette buffer.

image:SetPalette(palette: imPalette) [in Lua 5] 

void imImageCopyAttributes const imImage src_image,
imImage dst_image
 

Copies the image attributes from src to dst.

image:CopyAttributes(dst_image: imImage) [in Lua 5] 

int imImageMatchSize const imImage image1,
const imImage image2
 

Returns 1 if the images match width and height. Returns 0 otherwise.

image:MatchSize(image2: imImage) -> match: boolean [in Lua 5] 

int imImageMatchColor const imImage image1,
const imImage image2
 

Returns 1 if the images match color mode and data type. Returns 0 otherwise.

image:MatchColor(image2: imImage) -> match: boolean [in Lua 5] 

int imImageMatchDataType const imImage image1,
const imImage image2
 

Returns 1 if the images match width, height and data type. Returns 0 otherwise.

image:MatchDataType(image2: imImage) -> match: boolean [in Lua 5] 

int imImageMatchColorSpace const imImage image1,
const imImage image2
 

Returns 1 if the images match width, height and color space. Returns 0 otherwise.

image:MatchColorSpace(image2: imImage) -> match: boolean [in Lua 5] 

int imImageMatch const imImage image1,
const imImage image2
 

Returns 1 if the images match in width, height, data type and color space. Returns 0 otherwise.

image:Match(image2: imImage) -> match: boolean [in Lua 5] 

void imImageSetBinary imImage image  ) 
 

Changes the image space from gray to binary by just changing color_space and the palette.

image:SetBinary() [in Lua 5] 

void imImageMakeBinary imImage image  ) 
 

Changes a gray data into a binary data, done in-place.

image:MakeBinary() [in Lua 5]