IM: Image Storage

IM - An Imaging Tool

Image Storage


Detailed Description

See im.h

Modules

 File Format SDK
 imImage Storage
 File Formats

Data Structures

class  imImageFile
 C++ Wrapper for the Image File Structure. More...

Enumerations

enum  imErrorCodes {
  IM_ERR_NONE, IM_ERR_OPEN, IM_ERR_ACCESS, IM_ERR_FORMAT,
  IM_ERR_DATA, IM_ERR_COMPRESS, IM_ERR_MEM, IM_ERR_COUNTER
}

Functions

imFileimFileOpen (const char *file_name, int *error)
imFileimFileNew (const char *file_name, const char *format, int *error)
void imFileClose (imFile *ifile)
void * imFileHandle (imFile *ifile)
void imFileGetInfo (imFile *ifile, char *format, char *compression, int *image_count)
void imFileSetInfo (imFile *ifile, const char *compression)
void imFileSetAttribute (imFile *ifile, const char *attrib, int data_type, int count, const void *data)
const void * imFileGetAttribute (imFile *ifile, const char *attrib, int *data_type, int *count)
void imFileGetAttributeList (imFile *ifile, char **attrib, int *attrib_count)
void imFileGetPalette (imFile *ifile, long *palette, int *palette_count)
void imFileSetPalette (imFile *ifile, long *palette, int palette_count)
int imFileReadImageInfo (imFile *ifile, int index, int *width, int *height, int *file_color_mode, int *file_data_type)
int imFileWriteImageInfo (imFile *ifile, int width, int height, int user_color_mode, int user_data_type)
int imFileReadImageData (imFile *ifile, void *data, int convert2bitmap, int color_mode_flags)
int imFileWriteImageData (imFile *ifile, void *data)

Enumeration Type Documentation

enum imErrorCodes
 

File Access Error Codes

Enumerator:
IM_ERR_NONE  No error.
IM_ERR_OPEN  Error while opening the file (read or write).
IM_ERR_ACCESS  Error while accessing the file (read or write).
IM_ERR_FORMAT  Invalid or unrecognized file format.
IM_ERR_DATA  Invalid or unsupported data.
IM_ERR_COMPRESS  Invalid or unsupported compression.
IM_ERR_MEM  Insuficient memory
IM_ERR_COUNTER  Interrupted by the counter
00061 {
00062   IM_ERR_NONE,     /**< No error. */
00063   IM_ERR_OPEN,     /**< Error while opening the file (read or write). */
00064   IM_ERR_ACCESS,   /**< Error while accessing the file (read or write). */
00065   IM_ERR_FORMAT,   /**< Invalid or unrecognized file format. */
00066   IM_ERR_DATA,     /**< Invalid or unsupported data. */
00067   IM_ERR_COMPRESS, /**< Invalid or unsupported compression. */
00068   IM_ERR_MEM,      /**< Insuficient memory */
00069   IM_ERR_COUNTER   /**< Interrupted by the counter */
00070 };


Function Documentation

imFile* imFileOpen const char *  file_name,
int *  error
 

Opens the file for reading. It must exists. Also reads file header.

imFile* imFileNew const char *  file_name,
const char *  format,
int *  error
 

Creates a new file for writing. If the file exists will be replaced.
It will only initialize the format driver and create the file, no data is actually written.

void imFileClose imFile ifile  ) 
 

Closes the file

void* imFileHandle imFile ifile  ) 
 

Returns the internal handle. It is file format dependent.

void imFileGetInfo imFile ifile,
char *  format,
char *  compression,
int *  image_count
 

Returns file information. image_count is the number of images in a stack or the number of frames in a video/animation or the depth of a volume data.
compression and image_count can be NULL.

void imFileSetInfo imFile ifile,
const char *  compression
 

Changes the write compression method.
If the compression is not supported will return an error code when writting.
Use NULL to set the default compression. You can use the imFileGetInfo to retrieve the actual compression but only after imFileWriteImageInfo. Only a few formats allow you to change the compression between frames.

void imFileSetAttribute imFile ifile,
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.

const void* imFileGetAttribute imFile ifile,
const char *  attrib,
int *  data_type,
int *  count
 

Returns an extended attribute.
Returns NULL if not found. data_type and count can be NULL.

void imFileGetAttributeList imFile ifile,
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 imFileGetPalette imFile ifile,
long *  palette,
int *  palette_count
 

Returns the pallete if any.
"palette" must be a 256 colors alocated array.
Returns zero in "palette_count" if there is no palette. "palette_count" is >0 and <=256.

void imFileSetPalette imFile ifile,
long *  palette,
int  palette_count
 

Changes the pallete.
"palette_count" is >0 and <=256.

int imFileReadImageInfo imFile ifile,
int  index,
int *  width,
int *  height,
int *  file_color_mode,
int *  file_data_type
 

Reads the image header if any and returns image information.
Reads also the extended image attributes, so other image attributes will be available only after calling this function.
Returns an error code. index specifies the image number between 0 and image_count-1.
Some drivers reads only in sequence, so "index" can be ignored by the format driver.
Any parameters can be NULL. This function must be called at least once, check each format documentation.

int imFileWriteImageInfo imFile ifile,
int  width,
int  height,
int  user_color_mode,
int  user_data_type
 

Writes the image header. Writes the file header at the first time it is called. Writes also the extended image attributes.
Must call imFileSetPalette and set other attributes before calling this function.
In some formats the color space will be converted to match file format specification.
Returns an error code. This function must be called at least once, check each format documentation.

int imFileReadImageData imFile ifile,
void *  data,
int  convert2bitmap,
int  color_mode_flags
 

Reads the image data with or without conversion.
The data can be converted to bitmap when reading. Data type conversion to byte will always scan for min-max then scale to 0-255, except integer values that min-max are already between 0-255. Complex to real conversions will use the magnitude.
Color mode flags contains packed, alpha and top-botttom information. If flag is 0 means unpacked, no alpha and bottom up. If flag is -1 the file original flags are used.
Returns an error code.

int imFileWriteImageData imFile ifile,
void *  data
 

Writes the image data.
Returns an error code.