SetDIBits

  int SetDIBits(hdc, hbmp, uStartScan, cScanLines, lpvBits, lpbmi, fuColorUse)    
  HDC hdc; /* handle of device context */
  HBITMAP hbmp; /* handle of bitmap */
  UINT uStartScan; /* starting scan line */
  UINT cScanLines; /* number of scan lines */
  CONST VOID *lpvBits; /* array of bitmap bits */
  LPBITMAPINFO lpbmi; /* address of structure with bitmap data */
  UINT fuColorUse; /* type of color indices to use */

The SetDIBits function sets the pixels in the given bitmap using the color data found in the given device-independent bitmap (DIB).

Parameters

hdc

Identifies a device context.

hbmp

Identifies the bitmap that is altered using the color data from the given DIB.

uStartScan

Specifies the starting scanline for the device-independent color-data in lpvBits.

cScanLines

Specifies the number of scanlines found in the array containing device-independent color data.

lpvBits

Points to the DIB color-data stored as an array of bytes. The format of the bitmap values depends on the biBitCount member of the BITMAPINFO structure identified by lpbmi.

lpbmi

Points to a BITMAPINFO data structure that contains information about the DIB. The BITMAPINFO structure has the following form:

typedef struct tagBITMAPINFO { /* bmi */

BITMAPINFOHEADER bmiHeader;

RGBQUAD bmiColors[1];

} BITMAPINFO;

fuColorUse

Specifies whether the bmiColors field of the BITMAPINFO structure was provided and if so, whether bmiColors contains explicit RGB values or palette indices. The fuColorUse parameter must be one of the following values:

Value Meaning

DIB_PAL_COLORS  
  The color table is provided and consists of an array of 16-bit indices into the logical palette of the device context identified by hdc.
DIB_RGB_COLORS  
  The color table is provided and contains literal RGB values.
DIB_PAL_INDICES  
  No color table is provided. The array contains indexes into the the system palette.

Return Value

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

Comments

Optimal bitmap drawing speed is obtained when the bitmap bits are indices into the system palette.

Applications can retrieve the system palette colors and indices by calling the GetSystemPaletteEntries function. Once the colors and indices are retrieved, the application can create the DIB. (For more information about the system palette, see Chapter 70, “Colors and Color Palettes.”)

The device context identified by hdc is used only if the DIB_PAL_COLORS constant is set for fuColorUse; otherwise it is ignored.

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 is the bottom-left corner of the bitmap.

See Also

BITMAPINFO, GetSystemPaletteEntries