GetDIBits

3.0

  int GetDIBits(hdc, hbmp, nStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)    
  HDC hdc; /* handle of device context */
  HBITMAP hbmp; /* handle of bitmap, */  
  UINT nStartScan; /* first scan line to set in destination bitmap */
  UINT cScanLines; /* number of scan lines to copy */
  void FAR* lpvBits; /* address of array for bitmap bits */
  BITMAPINFO FAR* lpbmi; /* address of structure with bitmap data */
  UINT fuColorUse; /* type of color table */

The GetDIBits function retrieves the bits of the specified bitmap and copies them, in device-independent format, into the buffer pointed to by the lpvBits parameter. The lpbmi parameter retrieves the color format for the device-independent bits.

Parameters

hdc

Identifies the device context.

hbmp

Identifies the bitmap.

nStartScan

Specifies the first scan line to be set in the bitmap received in the lpvBits parameter.

cScanLines

Specifies the number of lines to be copied.

lpvBits

Points to a buffer that will receive the bitmap bits in device-independent format.

lpbmi

Points to a BITMAPINFO structure that specifies the color format and dimension for the device-independent bitmap. The BITMAPINFO structure has the following form:

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

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

fuColorUse

Specifies whether the bmiColors members of the BITMAPINFO structure are to contain explicit RGB values or indices into the currently realized logical palette. The fuColorUse parameter must be one of the following values:

Value Meaning

DIB_PAL_COLORS Color table is to consist of an array of 16-bit indices into the currently realized logical palette.
DIB_RGB_COLORS Color table is to contain literal RGB values.

Return Value

The return value specifies the number of scan lines copied from the bitmap if the function is successful. Otherwise, it is zero.

Comments

If the lpvBits parameter is NULL, the GetDIBits function fills in the BITMAPINFO structure to which the lpbmi parameter points 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 device-independent bitmaps (DIBs) is the lower-left corner of the bitmap, not the upper-left corner, which is the origin when the mapping mode is MM_TEXT.

See Also

SetDIBits