Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CreateBitmapIndirect function

The CreateBitmapIndirect function creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel).

Syntax


HBITMAP CreateBitmapIndirect(
  _In_  const BITMAP *lpbm
);

Parameters

lpbm [in]

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.

Return value

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.

Return codeDescription
ERROR_INVALID_PARAMETER

One or more of the input parameters is invalid.

ERROR_NOT_ENOUGH_MEMORY

The bitmap is too big for memory to be allocated.

 

Remarks

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.

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
BitBlt
BITMAP
CreateBitmap
CreateCompatibleBitmap
CreateDIBitmap
DeleteObject
SelectObject

 

 

Community Additions

Show:
© 2014 Microsoft