![]()
Introduction to the image library
The IO image library is part of the flib library. A set of routines allows to read and write images in a structured file.
File format
The format of an image file is very flexible. Constraints on the number and relative position of the different blocks are minimal and often purely of a logical nature (for example, "the header must come before the pixel blocks" rather than more static constraints such as "the header begins at offset 124").
An image file being first and foremost a file (as far as flib is concerned) the user is free to insert extra blocks. A minimal image is composed of a FOR4 group (aligned to a word) of CIMG type containing, in the following order:
- a BMHD header (bitmap header)
- a FOR4 group of type TBMP (tiled bitmap)
Pixel information is contained in the TBMP group, which can be quickly skipped if necessary.
In its minimal version, the TBMP group contains pixel related data blocks, in some order. For example, for a picture divided in four tiles we have:
FOR4 <size> CIMG BMHD 24 ... definition of size, maps, etc... FOR4 <size2> TBMP RGBA <ttile1> ... tile 1 pixels ... RGBA <ttile2> ... tile 2 pixels ... RGBA <ttile3> ... tile 3 pixels ... RGBA <ttile4> ... tile 4 pixels ...The header is defined by structure ILheader. RGBA blocks have the following structure:
[x1, y1, x2, y2] : tile coordinates (2 bytes each)
[pixels] : encoded according to compression mode.
If the image has a z-buffer, it is described by ZBUF blocks with the same structure as the RGBA blocks, RLE encoded.
- End fields. They display at the end of any image data, and will be displayed by fcheck. Calls to FLIB after image loading can be used to check for and retrieve this data. ILIB ignores these fields. The following four fields provide information about the image:
HIST—string data giving the Maya command line from which this image was created.
VERS—string data giving the Maya cut information.
CLPZ—depth map specific field giving the clipping planes used. This information is stored as two float values.
ESXY—eye x-y ratios. This is a depth map specific field used to compute the xy eye coordinates from the normalized pixel coordinates stored as two float values.
Functions
Some functions allow the reading and writing of images in line to line mode without worrying about tile management. Images can also be automatically zoomed and/or corrected (by lookup) during read (correction on compressed data being significantly more efficient). Finally, an automatic conversion system makes it possible to read images stored under other formats.
For more details on routines from the image library, see the man pages as well as "includes" and examples provided with the library.