ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5


2 - We All Need a Head(er)

In order to understand the data, the raw ebm images need a header to be usable, and the IMAGE structure provides this information:

struct IMAGE
{
U16 img_width, img_height, img_rowbytes;
COLOR_MODE img_colmode;
U8 unused;
COLOR *img_palette;
U8 *img_buffer;
};

Most of the items are obvious; img_width and img_height are the dimensions; img_colmode is the bitplane value (any of the COLOR_MODE_ values), and unused is, well, unused. img_palette is also unused at this time, and should be set to NULL. img_rowbytes is a pre-calculated value - it represents the number of bytes containing a row, and can be found using the following formula:

( img_width + 1<<bitsPerPixel - 1 ) >> bitsPerPixel

The last value to consider, img_buffer, can be two values - either a pointer to the image data, or NULL, which indicates that the image data immediately follows the IMAGE structure. In this way, you can create a position-independent bitmap, or manage the two pieces of data separately.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice