Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This structure defines the dimensions and color information of a Windows-based device-independent bitmap (DIB).

Syntax

typedef struct tagBITMAPINFO { 
  BITMAPINFOHEADER 
bmiHeader; 
  RGBQUAD 
bmiColors[1]; 
} BITMAPINFO; 

Members

bmiHeader

Specifies a bitmap information header structure that contains information about the dimensions of color format. Use the BITMAPINFOHEADERstructure.

bmiColors

Contains one of the following:

  • An array of RGBQUAD. The elements of the array make up the color table.

  • An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette.

    This use of bmiColorsis allowed for functions that use DIBs. When bmiColorselements contain indexes to a realized logical palette, they must also call the following bitmap functions: CreateDIBPatternBrushPtand CreateDIBSection. The iUsageparameter of CreateDIBSectionmust be set to DIB_PAL_COLORS.

    The number of entries in the array depends on the values of the biBitCountand biClrUsedmembers of the BITMAPINFOHEADERstructure.

    The colors in the bmiColorstable appear in order of importance. For more information, see the "Remarks" section.

  • If bmiHeader.biCompressionis set to BI_RGB, you can set the size of the bmiColorsarray to 0.

Remarks

A device-independent bitmap consists of two distinct parts: a BITMAPINFOstructure 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 LONGdata-type boundary.

If the height of the bitmap 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.

A bitmap is packed when the bitmap array immediately follows the BITMAPINFOheader. Packed bitmaps are referenced by a single pointer.

For packed bitmaps, the ClrUsedmember of the BITMAPINFOHEADERstructure must be set to an even number when using the DIB_PAL_COLORS mode so the DIB bitmap array starts on a DWORDboundary.

The bmiColorsmember should not contain palette indexes if the bitmap is 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.

Security Note:
A common class of errors involves not validating format descriptions that are found in the content. For example, a BITMAPINFOHEADERstructure can be followed by a color table.

The BITMAPINFOstructure is defined as a BITMAPINFOHEADERstructure followed by an array of RGBQUADvalues that make up the color table. The size of the array is determined by the value of biClrUsed.

Never copy a color table into a BITMAPINFOwithout first checking the size of the buffer that was allocated for the BITMAPINFOstructure.

Requirements

Header windows.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also