int GetDIBits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbi, uUsage) | |||||
HDC hdc; | /* handle of the device context | */ | |||
HBITMAP hbmp; | /* handle of the bitmap | */ | |||
UINT uStartScan; | /* first scan line to set in destination bitmap | */ | |||
UINT cScanLines; | /* number of scan lines to copy | */ | |||
LPVOID lpvBits; | /* address of array for bitmap bits | */ | |||
LPBITMAPINFO lpbi; | /* address of structure with bitmap data | */ | |||
UINT uUsage; | /* RGB or palette index | */ |
The GetDIBits function retrieves the bits of the specified bitmap and copies them into the given buffer using the specified format.
hdc
Identifies the device context.
hbmp
Identifies the bitmap.
uStartScan
Specifies the first scan line to retrieve.
cScanLines
Specifies the number of scan lines to be retrieved.
lpvBits
Points to a buffer that will receive the bitmap data. If this parameter is NULL, then the dimensions and format of the bitmap will be written into the BITMAPINFO structure pointed to by lpbi.
lpbi
Points to a BITMAPINFO structure that specifies the desired format for the device-independent bitmap data. The BITMAPINFO structure has the following form:
typedef struct tagBITMAPINFO { /* bmi */
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
uUsage
Specifies the format of the bmiColors member of the BITMAPINFO structure. It must be one of the following values:
Value | Meaning |
DIB_PAL_COLORS | The color table should consist of an array of 16-bit indices into the currently realized logical palette. |
DIB_RGB_COLORS | The color table should consist of literal RGB values. |
DIB_PAL_INDICES | No color table is returned. Just the BITMAPINFOHEADER portion of the BITMAPINFO will be filled in. |
The return value specifies the number of scan lines copied from the bitmap if the function is successful. Otherwise it is zero.
If the requested format for the DIB matches it's internal format, the RGB values for the bitmap will be copied. If the requested format doesn't match the internal format a color table will be synthesized. The following describes the color table synthesized for each format:
Value | Meaning |
1_BPP | The color table will consist of a black and white entry. |
4_BPP | The color table will consist of a mix of colors which is identical to the standard VGA palette. |
8_BPP | The color table will consist of a general mix of colors. |
24_BPP | No color table is returned. |
If lpvBits is a valid pointer, the first 6 members of the BITMAPINFOHEADER must be initialized to specify the size and format of the device-independent bitmap.
If lpvBits is valid pointer, the bitmap's color table will be appended to the BITMAPINFO data structure.
If the lpvBits is a valid pointer, GetDIBits fills in the BITMAPINFO structure at lpbi, but does not retrieve bits from the bitmap.
The bitmap identified by the hbmp parameter must not be selected into a device context when the application calls this function.
The origin for the device-independent bitmap is the bottom-left corner of the bitmap, not the top-left corner.
BITMAPINFO, BITMAPINFOHEADER