那是一个 API,
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Wingdi.h;
include Windows.h.
Library: Use Gdi32.lib.
SetDIBits
The SetDIBits function sets the pixels in a bitmap using the color data found in the specified DIB .
int SetDIBits(
HDC hdc, // handle to DC
HBITMAP hbmp, // handle to bitmap
UINT uStartScan, // starting scan line
UINT cScanLines, // number of scan lines
CONST VOID *lpvBits, // array of bitmap bits
CONST BITMAPINFO *lpbmi, // bitmap data
UINT fuColorUse // type of color indexes to use
);
Parameters
hdc
[in] Handle to a device context.
hbmp
[in] Handle to the bitmap that is to be altered using the color data from the specified DIB.
uStartScan
[in] Specifies the starting scan line for the device-independent color data in the array pointed to by the lpvBits parameter.
cScanLines
[in] Specifies the number of scan lines found in the array containing device-independent color data.
lpvBits
[in] 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] Pointer to a BITMAPINFO structure that contains information about the DIB.
fuColorUse
[in] Specifies 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. Value Meaning
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 Values
If the function succeeds, the return value is the number of scan lines copied.
If the function fails, the return value is zero.
Windows NT/ 2000: To get extended error information, call GetLastError. This can be the following value.
Value Meaning
ERROR_INVALID_PARAMETER One or more input parameters are 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. The color profile of the current device context is used as the source color space profile and the sRGB color space is used.
See Also
Bitmaps Overview, Bitmap Functions, GetDIBits, GetSystemPaletteEntries, BITMAPINFO