The BITMAPINFO data structure defined by Windows is used with many of the compression and decompression messages to pass information about the bitmaps being compressed and decompressed. This structure has the following members:
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader; // BITMAPINFOHEADER data
RGBQUAD bmiColors[]; // Color table
} BITMAPINFO;
The bmiColors member is used for the color table. The BITMAPINFOHEADER data defined for the bmiHeader member is used to pass information about the format of the bitmaps being compressed and decompressed. This structure has the following members:
typedef struct tagBITMAPINFOHEADER {
DWORD biSize; // Structure size
LONG biWidth; // Width of the bitmap
LONG biHeight; // Heifht of the bitmap
WORD biPlanes; // Planes of the target device
WORD biBitCount; // Number of bits per pixel
DWORD biCompression; // Compression type
DWORD biSizeImage; // Bytes contained in the image
LONG biXPelsPerMeter; // Horizontal resolution
LONG biYPelsPerMeter; // Vertical resolutioni
DWORD biClrUsed; // Number of color indexes
DWORD biClrImportant; // Number of important colors
} BITMAPINFOHEADER;
The biCompression member specifies the type of compression used or requested. Windows defines the following compression formats:
Format | Description |
---|---|
BI_RGB | Specifies the bitmap is not compressed. |
BI_RLE8 | Specifies a run-length encoded format for bitmaps with 8 bits per pixel. |
BI_RLE4 | Specifies a run-length encoded format for bitmaps with 4 bits per pixel. |
Video for Windows extends the BI_RGB format to include 16 and 32 bits per pixel bitmap formats. These formats do not use a color table. They embed the colors in the WORD or DWORD representing each pixel.
The 16 bit BI_RGB format is identified by setting biCompression to BI_RGB and setting biBitCount to 16. For this format, each pixel is represented by a 16-bit RGB color value. The high-bit of this value is zero. The remaining bits are divided into 3 groups of 5-bits to represent the red, green, and blue color values.
The 32 bit BI_RGB format is identified by setting biCompression to BI_RGB and setting biBitCount to 32. For this format, each pixel is represented by a 32 bit (4 byte) RGB color value. One byte is used for each red, green, and blue color value. The fourth byte is set to zero.
Your driver should support the BI_RGB format for 8 bit per pixel bitmaps. If practical, it should also support this format for 16, 24, and 32 bits per pixel bitmaps.
In addition to the new BI_RGB formats, the BI_BITFIELD format adds new compression capabilities. This format specifies a bitmap is not compressed and color masks are defined in the bmiColors member of the BITMAPINFO data structure. The first DWORD in the bmiColors member is the red mask, the second DWORD is the green mask, and the third DWORD is the blue mask.
Your driver can also extend the format set by defining custom formats. Custom formats use a four character code for the format in the biCompression member in place of the standard constants. Your driver can use a custom format to support a unique or nonstandard compression type. When you define a custom format, you can specify values other than 1, 4, 8, 16, 24, or 32 for the biBitCount member.