Export (0) Print
Expand All

SetDIBits function

The SetDIBits function sets the pixels in a compatible bitmap (DDB) using the color data found in the specified DIB.

Syntax


int SetDIBits(
  _In_  HDC hdc,
  _In_  HBITMAP hbmp,
  _In_  UINT uStartScan,
  _In_  UINT cScanLines,
  _In_  const VOID *lpvBits,
  _In_  const BITMAPINFO *lpbmi,
  _In_  UINT fuColorUse
);

Parameters

hdc [in]

A handle to a device context.

hbmp [in]

A handle to the compatible bitmap (DDB) that is to be altered using the color data from the specified DIB.

uStartScan [in]

The starting scan line for the device-independent color data in the array pointed to by the lpvBits parameter.

cScanLines [in]

The number of scan lines found in the array containing device-independent color data.

lpvBits [in]

A pointer 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 pointed to by the lpbmi parameter.

lpbmi [in]

A pointer to a BITMAPINFO structure that contains information about the DIB.

fuColorUse [in]

Indicates whether the bmiColors member of the BITMAPINFO structure was provided and, if so, whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The fuColorUse parameter must be one of the following values.

ValueMeaning
DIB_PAL_COLORS

The color table consists of an array of 16-bit indexes into the logical palette of the device context identified by the hdc parameter.

DIB_RGB_COLORS

The color table is provided and contains literal RGB values.

 

Return value

If the function succeeds, the return value is the number of scan lines copied.

If the function fails, the return value is zero.

This can be the following value.

Return codeDescription
ERROR_INVALID_PARAMETER

One or more of the input parameters is invalid.

 

Remarks

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

Applications can retrieve the system palette colors and indexes by calling the GetSystemPaletteEntries function. After the colors and indexes are retrieved, the application can create the DIB. For more information, see System Palette.

The device context identified by the hdc parameter is used only if the DIB_PAL_COLORS constant is set for the fuColorUse parameter; 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 scan lines must be aligned on a DWORD except for RLE-compressed bitmaps.

The origin for bottom-up DIBs is the lower-left corner of the bitmap; the origin for top-down DIBs is the upper-left corner of the bitmap.

ICM: Color management is performed if color management has been enabled with a call to SetICMMode with the iEnableICM parameter set to ICM_ON. If the bitmap specified by lpbmi has a BITMAPV4HEADER that specifies the gamma and endpoints members, or a BITMAPV5HEADER that specifies either the gamma and endpoints members or the profileData and profileSize members, then the call treats the bitmap's pixels as being expressed in the color space described by those members, rather than in the device context's source color space.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Wingdi.h (include Windows.h)

Library

Gdi32.lib

DLL

Gdi32.dll

See also

Bitmaps Overview
Bitmap Functions
GetDIBits
GetSystemPaletteEntries
BITMAPINFO

 

 

Community Additions

ADD
Show:
© 2014 Microsoft