2.12 Device-Independent Bitmap Functions

Microsoft Windows provides a set of functions that define and manipulate color bitmaps so that they can be appropriately displayed on a device with a given resolution, regardless of the method used by the device to represent color in memory. These functions translate a device-independent bitmap (DIB) specification into a device-specific format.

A DIB specification consists of two parts:

A BITMAPINFO structure that defines the format of the bitmap and, optionally, supplies a table of colors used by the bitmap

An array of bytes that contain the bitmap bit values

Depending on the values contained in the bitmap information structure, the bitmap bit values can specify explicit RGB color values or indices into the color table. In addition, the color table can consist of indices into the currently realized logical palette instead of explicit RGB color values. Note that the coordinate-system origin for DIBs is the lower-left corner, not the Windows default upper-left corner.

Following are the DIB functions:

Function Description

CreateDIBitmap Creates a device-specific memory bitmap from a DIB specification and, optionally, initializes bits in the bitmap. This function is similar to the CreateBitmap function.
GetDIBits Retrieves the bits in memory for a specific bitmap in device-independent form. This function is similar to the GetBitmapBits function.
SetDIBits Sets bits of a memory bitmap from a DIB. This function is similar to the SetBitmapBits function.
SetDIBitsToDevice Sets bits on a device surface directly from a DIB.
StretchDIBits Moves a DIB from a source rectangle into a destination rectangle, stretching or compressing the bitmap as required.