HBITMAP CreateCompatibleBitmap(hdc, nWidth, nHeight) | |||||
HDC hdc; | /* handle of device context | */ | |||
int nWidth; | /* width of bitmap in pixels | */ | |||
int nHeight; | /* height of bitmap in pixels | */ |
The CreateCompatibleBitmap function creates a bitmap that is compatible with the device that is associated with the given device context.
hdc
Identifies a device context.
nWidth
Specifies the bitmap width in pixels.
nHeight
Specifies the bitmap height in pixels.
The return value identifies a bitmap if the function is successful. Otherwise, it is 0.
The color format of the bitmap created by this function matches the color format of the device identified by hdc. This bitmap can be selected into any memory DC that is compatible with the original device.
Since memory DCs allow both color or monochrome bitmaps, the format of the bitmap returned by the CreateCompatibleBitmap function varies when the specified DC is a memory DC. However, a compatible bitmap that was created for a nonmemory DC always possesses the same color format and uses the same color palette as the specified DC.
DeleteObject, SelectObject