Data Structures | Modules | Defines | Typedefs | Functions

imImage
[Image Representation]

Collaboration diagram for imImage:

Data Structures

struct  _imImage
 Image Representation Structure. More...

Modules

 Image Conversion

Defines

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

Typedefs

typedef struct _imImage imImage

Functions

imImageimImageCreate (int width, int height, int color_space, int data_type)
imImageimImageInit (int width, int height, int color_mode, 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 imImageSetAlpha (imImage *image, double alpha)
void imImageRemoveAlpha (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)
void imImageCopyAttributes (const imImage *src_image, imImage *dst_image)
void imImageMergeAttributes (const imImage *src_image, imImage *dst_image)
void imImageCopyPlane (const imImage *src_image, int src_plane, imImage *dst_image, int dst_plane)
imImageimImageDuplicate (const imImage *image)
imImageimImageClone (const imImage *image)
void imImageSetAttribute (const imImage *image, const char *attrib, int data_type, int count, const void *data)
void imImageSetAttribInteger (const imImage *image, const char *attrib, int data_type, int value)
void imImageSetAttribReal (const imImage *image, const char *attrib, int data_type, double value)
void imImageSetAttribString (const imImage *image, const char *attrib, const char *value)
const void * imImageGetAttribute (const imImage *image, const char *attrib, int *data_type, int *count)
int imImageGetAttribInteger (const imImage *image, const char *attrib, int index)
double imImageGetAttribReal (const imImage *image, const char *attrib, int index)
const char * imImageGetAttribString (const imImage *image, const char *attrib)
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)
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 imImageSetMap (imImage *image)
void imImageSetBinary (imImage *image)
void imImageSetGray (imImage *image)
void imImageMakeBinary (imImage *image)
void imImageMakeGray (imImage *image)

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

Define Documentation

#define imcdCanvasPutImage (   _canvas,
  _image,
  _x,
  _y,
  _w,
  _h,
  _xmin,
  _xmax,
  _ymin,
  _ymax 
)
Value:
{                                                                         \
    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.


Typedef Documentation

typedef struct _imImage imImage

Image Representation Structure.

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. 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_mode,
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. The only addtional flag thar color_mode can has here is IM_ALPHA. To release the image structure without releasing the buffer, set "data[0]" to NULL before calling imImageDestroy.

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 and sets its value to 0 (transparent).

image:AddAlpha() [in Lua 5] 
void imImageSetAlpha ( imImage image,
double  alpha 
)

Sets the alpha channel plane to a constant.

image:SetAlpha(alpha: number) [in Lua 5] 
void imImageRemoveAlpha ( imImage image  ) 

Removes the alpha channel plane if any.

image:RemoveAlpha() [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] 
void imImageCopyAttributes ( const imImage src_image,
imImage dst_image 
)

Copies the image attributes from src to dst. Includes the pallete if defined in both images.

image:CopyAttributes(dst_image: imImage) [in Lua 5] 
void imImageMergeAttributes ( const imImage src_image,
imImage dst_image 
)

Merges the image attributes from src to dst.
Attributes that exist in dst are not replaced. Doens NOT include the pallete.

image:MergeAttributes(dst_image: imImage) [in Lua 5] 
void imImageCopyPlane ( const imImage src_image,
int  src_plane,
imImage dst_image,
int  dst_plane 
)

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

image:CopyPlane(src_plane: number, dst_image: imImage, dst_plane: number) [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 ( 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, a string can be used as data.

void imImageSetAttribInteger ( const imImage image,
const char *  attrib,
int  data_type,
int  value 
)

Changes an extended attribute as an integer.

image:SetAttribInteger(attrib: string, data_type: number, value: number) [in Lua 5] 
void imImageSetAttribReal ( const imImage image,
const char *  attrib,
int  data_type,
double  value 
)

Changes an extended attribute as a real.

image:SetAttribReal(attrib: string, data_type: number, value: number) [in Lua 5] 
void imImageSetAttribString ( const imImage image,
const char *  attrib,
const char *  value 
)

Changes an extended attribute as a string.

image:SetAttribString(attrib: string, value: string) [in Lua 5] 
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.

int imImageGetAttribInteger ( const imImage image,
const char *  attrib,
int  index 
)

Returns an extended attribute as an integer.

image:GetAttribInteger(attrib: string, [index: number]) -> value: number [in Lua 5] 
double imImageGetAttribReal ( const imImage image,
const char *  attrib,
int  index 
)

Returns an extended attribute as a real.

image:GetAttribReal(attrib: string, [index: number]) -> value: number [in Lua 5] 
const char* imImageGetAttribString ( const imImage image,
const char *  attrib 
)

Returns an extended attribute as a string.

image:GetAttribString(attrib: string) -> value: string [in Lua 5] 
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] 
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 imImageSetMap ( imImage image  ) 

Changes the image color space to map by just changing color_space.
Image must be BINARY or GRAY/BYTE.

image:SetMap() [in Lua 5] 
void imImageSetBinary ( imImage image  ) 

Changes the image color space to binary by just changing color_space and the palette. Image must be MAP or GRAY/BYTE.

image:SetBinary() [in Lua 5] 
void imImageSetGray ( imImage image  ) 

Changes the image color space to gray by just changing color_space and the palette. Image must be BINARY or MAP. Palette is changed only if image was BINARY.

image:SetGray() [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. Data type must be IM_BYTE.

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. Data type must be IM_BYTE.

image:MakeGray() [in Lua 5]