CreateBitmapIndirect function (wingdi.h)
The CreateBitmapIndirect function creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel).
HBITMAP CreateBitmapIndirect( const BITMAP *pbm );
A pointer to a BITMAP structure that contains information about the bitmap. If an application sets the bmWidth or bmHeight members to zero, CreateBitmapIndirect returns the handle to a 1-by-1 pixel, monochrome bitmap.
If the function succeeds, the return value is a handle to the bitmap.
If the function fails, the return value is NULL.
This function can return the following values.
||One or more of the input parameters is invalid.|
||The bitmap is too big for memory to be allocated.|
The CreateBitmapIndirect function creates a device-dependent bitmap.
After a bitmap is created, it can be selected into a device context by calling the SelectObject function. However, the bitmap can only be selected into a device context if the bitmap and the DC have the same format.
While the CreateBitmapIndirect function can be used to create color bitmaps, for performance reasons applications should use CreateBitmapIndirect to create monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. Whenever a color bitmap from CreateBitmapIndirect is selected into a device context, the system must ensure that the bitmap matches the format of the device context it is being selected into. Because CreateCompatibleBitmap takes a device context, it returns a bitmap that has the same format as the specified device context. Thus, subsequent calls to SelectObject are faster with a color bitmap from CreateCompatibleBitmap than with a color bitmap returned from CreateBitmapIndirect.
If the bitmap is monochrome, zeros represent the foreground color and ones represent the background color for the destination device context.
When you no longer need the bitmap, call the DeleteObject function to delete it.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|
|Header||wingdi.h (include Windows.h)|