BITMAPINFO
The BITMAPINFO
structure defines the dimensions and color information for a Windows
device-independent bitmap (DIB).
typedef struct tagBITMAPINFO { // bmi
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
Members
bmiHeader
Specifies a BITMAPINFOHEADER
bmiColors
Specifies an
array of RGBQUAD
Remarks
A
device-independent bitmap consists of two distinct parts: a BITMAPINFO
structure describing the dimensions and colors of the bitmap, and an array of
bytes defining the pixels of the bitmap. The bits in the array are packed
together, but each scan line must be padded with zeroes to end on a LONG
data-type boundary. If the height is positive, the bitmap is a bottom-up DIB
and its origin is the lower left corner. If the height is negative, the bitmap
is a top-down DIB and its origin is the upper left corner.
The biBitCount
member of the BITMAPINFOHEADER
Value |
Meaning |
1 |
The bitmap
is monochrome, and the bmiColors member contains two entries. Each bit
in the bitmap array represents a pixel. If the bit is clear, the pixel is
displayed with the color of the first entry in the bmiColors table; if
the bit is set, the pixel has the color of the second entry in the table. |
4 |
The bitmap
has a maximum of 16 colors, and the bmiColors member contains up to 16
entries. Each pixel in the bitmap is represented by a 4-bit index into the
color table. For example, if the first byte in the bitmap is 0x1F, the byte
represents two pixels. The first pixel contains the color in the second table
entry, and the second pixel contains the color in the sixteenth table entry. |
8 |
The bitmap
has a maximum of 256 colors, and the bmiColors member contains up to
256 entries. In this case, each byte in the array represents a single pixel. |
16 |
The bitmap
has a maximum of 2^16 colors. If the biCompression member of the BITMAPINFOHEADER If the biCompression
member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors
member contains three DWORD color masks that specify the red, green,
and blue components, respectively, of each pixel. Each WORD in the
bitmap array represents a single pixel. Windows
NT: When the biCompression
member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous
and should not overlap the bits of another mask. All the bits in the pixel do
not have to be used. Windows
95: When the biCompression
member is BI_BITFIELDS, Windows 95 supports only the following 16bpp color
masks: A 5-5-5 16-bit image, where the blue mask is 0x001F, the green mask is
0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, where the blue
mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800. |
24 |
The bitmap
has a maximum of 2^24 colors, and the bmiColors member is NULL. Each
3-byte triplet in the bitmap array represents the relative intensities of
blue, green, and red, respectively, for a pixel. |
32 |
The bitmap
has a maximum of 2^32 colors. If the biCompression member of the BITMAPINFOHEADER
is BI_RGB, the bmiColors member is NULL. Each DWORD in the
bitmap array represents the relative intensities of blue, green, and red,
respectively, for a pixel. The high byte in each DWORD is not used. If the biCompression
member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors
member contains three DWORD color masks that specify the red, green,
and blue components, respectively, of each pixel. Each DWORD in the
bitmap array represents a single pixel. Windows
NT: When the biCompression
member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous
and should not overlap the bits of another mask. All the bits in the pixel do
not have to be used. Windows
95: When the biCompression
member is BI_BITFIELDS, Windows 95 supports only the following 32bpp color
mask: The blue mask is 0x000000FF, the green mask is 0x0000FF00, and the red
mask is 0x00FF0000. |
The biClrUsed
member of the BITMAPINFOHEADER
The colors in
the bmiColors table should appear in order of importance.
Alternatively,
for functions that use DIBs, the bmiColors member can be an array of
16-bit unsigned integers that specify indices into the currently realized
logical palette, instead of explicit RGB values. In this case, an application
using the bitmap must call the DIB functions (CreateDIBitmap
If the bitmap
is a packed bitmap (a bitmap in which the bitmap array immediately follows the BITMAPINFO
header and which is referenced by a single pointer), the biClrUsed
member must be set to an even number when using the DIB_PAL_COLORS mode so the
DIB bitmap array starts on a doubleword boundary.
Note The bmiColors
member should not contain palette indices if the bitmap is to be stored in a
file or transferred to another application. Unless the application has
exclusive use and control of the bitmap, the bitmap color table should contain
explicit RGB values.
See Also