다음을 통해 공유


CreateDIBSection (Windows CE 5.0)

Send Feedback

This function creates a device-independent bitmap (DIB) that applications can write to directly. The function returns a handle to the bitmap.

HBITMAPCreateDIBSection(HDChdc, constBITMAPINFO* pbmi, UINTiUsage, void** ppvBits, HANDLEhSection, DWORDdwOffset);

Parameters

  • hdc
    [in] Handle to a device context.

    If the value of iUsage is DIB_PAL_COLORS, the function uses this device context's logical palette to initialize the device-independent bitmap's colors.

  • pbmi
    [in] Pointer to a BITMAPINFO structure that specifies various attributes of the device-independent bitmap, including the bitmap's dimensions and colors.

  • iUsage
    [in] Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure pointed to by pbmi (either logical palette indexes or literal RGB values).

    The following values are defined.

    Value Description
    DIB_RGB_COLORS The BITMAPINFO structure contains an array of bit masks or a palette depending on the value of the biCompression member of the structure. These values are used when rendering the bitmap.

    This value can be specified along with any bit count.

    DIB_PAL_COLORS The BITMAPINFO.bmiColors array is ignored, and the destination palette is used when rendering the bitmap.

    This value can only be specified with an 8-bpp bitmap.

  • ppvBits
    [in] Pointer to a variable that receives a pointer to the location of the device-independent bitmap's bit values.

  • hSection
    [in] Set this parameter to NULL.

  • dwOffset
    [in] Ignored.

Return Values

A handle to the newly created device-independent bitmap indicates success, and *ppvBits points to the bitmap's bit values.

NULL indicates failure, and *ppvBits is NULL.

To get extended error information, call GetLastError.

Remarks

The system allocates memory for the device-independent bitmap. The system closes the handle to that memory when you later delete the device-independent bitmap by calling the DeleteObject function.

In Windows CE 2.0 and later, the BITMAPINFO structure must include a color table if the images are palletized (usually 1-, 2-, 4-, and 8-bpp formats).

For 16-bpp or 32-bpp non-palletized images, the color table must be three entries long; the entries must specify the values of the red, green, and blue bitmasks.

Also, the biCompression member in the BITMAPINFOHEADER structure should be set to BI_BITFIELDS. BI_RGB is not supported for these bit depths. GDI ignores the color table for 24-bpp images; their pixels must be stored in Blue-Green-Red (BGR) format.

Windows CE does not support 332 bitfields devices.

In Windows CE 1.0 and 1.01, the BITMAPINFO structure pointed to by the pbmi parameter must specify 1 or 2 bits per pixel.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

DeleteObject | GetObject | SelectObject | BITMAPINFO | BITMAPINFOHEADER | GDI Functions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.