Share via


CreateCompatibleBitmap

This function creates a bitmap compatible with the device associated with the specified device context.

HBITMAP CreateCompatibleBitmap(
HDC hdc, 
int nWidth, 
int nHeight
); 

Parameters

  • hdc
    [in] Handle to a device context.
  • nWidth
    [in] Specifies the bitmap width, in pixels.
  • nHeight
    [in] Specifies the bitmap height, in pixels.

Return Values

A handle to the bitmap indicates success. NULL indicates failure. To get extended error information, call GetLastError.

Remarks

The color format of the bitmap created by the CreateCompatibleBitmap function matches the color format of the device identified by the hdc parameter. This bitmap can be selected into any memory device context that is compatible with the original device.

Because memory device contexts allow both color and monochrome bitmaps, the format of the bitmap returned by the CreateCompatibleBitmap function differs when the specified device context is a memory device context. However, a compatible bitmap that was created for a nonmemory device context always possesses the same color format and uses the same color palette as the specified device context.

If an application sets the nWidth or nHeight parameters to zero, CreateCompatibleBitmap returns the handle to a 1- by 1-pixel, monochrome bitmap.

If a DIB section, which is a bitmap created by the CreateDIBSection function, is selected into the device context identified by the hdc parameter, CreateCompatibleBitmap creates a DIB section.

When you no longer need the bitmap, call the DeleteObject function to delete it.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Wingdi.h   Mgbitmap.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CreateDIBSection, DeleteObject, GetLastError, SelectObject

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.