IM: Image Structure

IM - Imaging Libray

Image Structure
[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 0 before calling imImageDestroy.
See im_image.h


Data Structures

struct  _imImage
 Image Structure Definition. More...

Defines

#define cdPutBitmap(_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)
void imImageDestroy (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)
imImageimFileLoadImage (imFile *ifile, int index, int *error)
imImageimFileLoadBitmap (imFile *ifile, int index, int *error)
int imFileSaveImage (imFile *ifile, const imImage *image)
imImageimImageLoad (const char *file_name, int index, int *error)
imImageimImageLoadBitmap (const char *file_name, int index, int *error)
void imImageSetBinary (imImage *image)
void imImageMakeBinary (imImage *image)

Define Documentation

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

Value:

{                                                                         \
    if (_image->color_space == IM_RGB)                                      \
      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
 

Image Structure Definition.

An image representation than supports all the color spaces, but no alpha channel, 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.

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.

void imImageDestroy imImage image  ) 
 

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

void imImageReshape imImage image,
int  width,
int  height
 

Changes the buffer size. Reallocate internal buffers if they are larger than original.

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.

void imImageCopyData const imImage src_image,
imImage dst_image
 

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

imImage* imImageDuplicate const imImage image  ) 
 

Creates a copy of the image.

imImage* imImageClone const imImage image  ) 
 

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

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.

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

Returns an extended attribute.
Returns NULL if not found.

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.

void imImageClear imImage image  ) 
 

Sets all image data to zero.

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.

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.

void imImageCopyAttributes const imImage src_image,
imImage dst_image
 

Copies the image attributes from src to dst.

int imImageMatchSize const imImage image1,
const imImage image2
 

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

int imImageMatchColor const imImage image1,
const imImage image2
 

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

int imImageMatchDataType const imImage image1,
const imImage image2
 

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

int imImageMatchColorSpace const imImage image1,
const imImage image2
 

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

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.

imImage* imFileLoadImage imFile ifile,
int  index,
int *  error
 

Loads an image from file. Returns NULL if failed. This will call imFileReadImageInfo and imFileReadImageData.

imImage* imFileLoadBitmap imFile ifile,
int  index,
int *  error
 

Loads an image from file, but forces the image to be a bitmap.
Returns NULL if failed.

int imFileSaveImage imFile ifile,
const imImage image
 

Saves the image to file. Returns error code.
This will call imFileWriteImageInfo and imFileWriteImageData.

imImage* imImageLoad const char *  file_name,
int  index,
int *  error
 

Loads an image from file.
Returns NULL if failed.

imImage* imImageLoadBitmap const char *  file_name,
int  index,
int *  error
 

Loads an image from file, but forces the image to be a bitmap.
Returns NULL if failed.

void imImageSetBinary imImage image  ) 
 

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

void imImageMakeBinary imImage image  ) 
 

Changes a gray data into a binary data.