A device-independent bitmap (DIB) is a color bitmap in a format that eliminates the problems that occur when transferring device-dependent bitmaps to devices having difference bitmap formats. DIBs provide color and bitmap information that any display or printer driver can translate into the proper format for its corresponding device.
A display driver can support DIBs by providing the following device-independent bitmap functions. Because the DIB engine provides support for DIBs, the following functions are optional for a minidriver to implement.
Function | Description |
DeviceBitmapBits | Copies a DIB to a device-dependent bitmap or a device-dependent bitmap to a DIB. |
SetDIBitsToDevice | Copies any portion of a DIB to the screen. This function copies the bits directly without applying a raster operation. |
StretchDIBits | Moves a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle. |
These functions receive and operate on BITMAPINFO, BITMAPINFOHEADER, and RGBQUAD structures.
A display driver that supports DIBs must provide the CreateDIBitmap function as well. The function should do nothing more than return zero, indicating that the creation of a DIB is not supported at the driver level.
If a display driver supports DIBs, it must set one or more of the RC_DI_BITMAP, RC_DIBTODEV, and RC_STRETCHDIB values in the dpRaster member of the GDIINFO structure. If a driver does not set the RC_DI_BITMAP value, GDI simulates DIB conversions using monochrome bitmaps. The DIB engine supports of these capabilities and minidrivers may rely on the DIB engine for these functions.
Drivers use a logical-color table when translating a device-specific bitmap into a DIB. The table resides in the DIB header block. Because color mapping is a complex process, minidrivers should let the DIB engine create the logical color table.
A display driver can copy a DIB directly to the screen using the SetDIBitsToDevice function or call the DIB engine function DIB_DibToDevice. SetDIBitsToDevice saves the trouble of first converting the DIB into the device-dependent format and then, transferring it onto the screen. However, only a direct copy of the DIB is provided. Moreover, only one direction of copy (DIB to screen) is provided.