![]() |
Data Structures | |
struct | _imImage |
imImage Structure Definition. More... | |
Modules | |
Image Conversion | |
Defines | |
#define | imcdCanvasPutImage(_canvas, _image, _x, _y, _w, _h, _xmin, _xmax, _ymin, _ymax) |
Typedefs | |
typedef struct _imImage | imImage |
Functions | |
imImage * | imImageCreate (int width, int height, int color_space, int data_type) |
imImage * | imImageInit (int width, int height, int color_space, int data_type, void *data_buffer, long *palette, int palette_count) |
imImage * | imImageCreateBased (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) |
imImage * | imImageDuplicate (const imImage *image) |
imImage * | imImageClone (const imImage *image) |
void | imImageSetAttribute (const 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) |
void | imImageMakeGray (imImage *image) |
#define imcdCanvasPutImage | ( | _canvas, | |||
_image, | |||||
_x, | |||||
_y, | |||||
_w, | |||||
_h, | |||||
_xmin, | |||||
_xmax, | |||||
_ymin, | |||||
_ymax | ) |
{ \ if (_image->color_space == IM_RGB) \ { \ if (_image->has_alpha) \ cdCanvasPutImageRectRGBA(_canvas, _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 \ cdCanvasPutImageRectRGB(_canvas, _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 \ cdCanvasPutImageRectMap(_canvas, _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.
imImage Structure Definition.
imImage* imImageCreate | ( | int | width, | |
int | height, | |||
int | color_space, | |||
int | data_type | |||
) |
Creates a new image. See also imDataType and imColorSpace. Image data is cleared as imImageClear.
In Lua the IM image metatable name is "imImage". When converted to a string will return "imImage(%p) [width=%d,height=%d,color_space=%s,data_type=%s,depth=%d]" where p is replaced by the userdata address, and other values are replaced by the respective attributes. If the image is already destroyed by im.ImageDestroy, then it will return also the suffix "-destroyed".
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. HasAlpha is 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 can be nil, and they can also be functions with the based image as a parameter to return the respective value.
void imImageDestroy | ( | imImage * | image | ) |
Destroys the image and frees the memory used. image data is destroyed only if its data[0] is not NULL.
In Lua if this function is not called, the image is destroyed by the garbage collector.
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]
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]
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]
Creates a copy of the image.
image:Duplicate() -> new_image: imImage [in Lua 5]
Creates a clone of the image. i.e. same attributes but ignore contents.
image:Clone() -> new_image: imImage [in Lua 5]
void imImageSetAttribute | ( | const 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 and count==0 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. But if color space is YCBCR, LAB or LUV, and data type is BYTE or USHORT, then data is initialized with 128 or 32768 accordingly. Alpha is initialized as transparent (0).
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 pointer. Only the pointer is stored, so the palette should be a new palette and it can not be a static array.
image:SetPalette(palette: imPalette) [in Lua 5]
Copies the image attributes from src to dst.
image:CopyAttributes(dst_image: imImage) [in Lua 5]
Returns 1 if the images match width and height. Returns 0 otherwise.
image:MatchSize(image2: imImage) -> match: boolean [in Lua 5]
Returns 1 if the images match color mode and data type. Returns 0 otherwise.
image:MatchColor(image2: imImage) -> match: boolean [in Lua 5]
Returns 1 if the images match width, height and data type. Returns 0 otherwise.
image:MatchDataType(image2: imImage) -> match: boolean [in Lua 5]
Returns 1 if the images match width, height and color space. Returns 0 otherwise.
image:MatchColorSpace(image2: imImage) -> match: boolean [in Lua 5]
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 color 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 BYTE data (0,255) into a binary data (0,1), done in-place. Color space is not changed.
image:MakeBinary() [in Lua 5]
void imImageMakeGray | ( | imImage * | image | ) |
Changes a binary data (0,1) into a gray BYTE data (0,255), done in-place. Color space is not changed.
image:MakeGray() [in Lua 5]