HBITMAP CreateCompatibleBitmap(hDC,nWidth,nHeight)
This function creates a bitmap that is compatible with the device specified by the hDC parameter. The bitmap has the same number of color planes or the same bits-per-pixel format as the specified device. It can be selected as the current bitmap for any memory device that is compatible with the one specified by hDC.
If hDC is a memory device context, the bitmap returned has the same format as the currently selected bitmap in that device context. A memory device context is a block of memory that represents a display surface. It can be used to prepare images in memory before copying them to the actual display surface of the compatible device.
When a memory device context is created, GDI automatically selects a monochrome stock bitmap for it.
Since a color memory device context can have either color or monochrome bitmaps selected, the format of the bitmap returned by the CreateCompatibleBitmap function is not always the same; however, the format of a compatible bitmap for a nonmemory device context is always in the format of the device.
Parameter | Type/Description |
hDC | HDC Identifies the device context. | |
nWidth | int Specifies the width (in bits) of the bitmap. | |
nHeight | int Specifies the height (in bits) of the bitmap. |
The return value identifies a bitmap if the function is successful. Otherwise, it is NULL.