Bitmaps

GDI requires a display driver to support bit-block transfers by providing the BitBlt and related bitmap functions. A display driver must provide a BitBlt function that can carry out bitmap operations on the screen, color bitmaps, and monochrome bitmaps. The brute functions provided by GDI and used by many printer drivers require monochrome bitmap support.

Bitmap Format

Most display devices are either planar or packed-pixel devices. A planar device stores screen bits in separate bitmap planes, each representing a distinct color. A packed-pixel device stores screen bits in a single plane, but each pixel on the screen has a set of four or more corresponding bits that define the pixel color.

A display driver specifies the type of display device by setting the dpBitsPixel and dpPlanes members to appropriate values. For a planar device, dpBitsPixel is 1 and dpPlanes specifies the number of planes. For a packed-pixel device, dpPlanes is 1 and dpBitsPixel specifies the number of bits per pixel. The DIB engine provides support for only the packed-pixel format.

These values also help determine the number of nondithered colors available for the screen. A device with four planes is capable of 16 colors. A device with 8 bits per pixel is capable of 256 colors. However, the exact color specified by a combination of bits depends on whether the device supports a color palette.

Pixel Output

A display driver must support setting and getting individual pixels by providing the Pixel function. GDI uses Pixel to support a variety of simulations. It also calls the function whenever an application calls SetPixel (GDI.31) and GetPixel (GDI.83).

Bit-Block Transfers

A display driver must support bit-block transfers by setting the dpRaster member to RC_BITBLT and providing a BitBlt function. GDI uses BitBlt to copy a rectangular block of bits from bitmap to bitmap, possibly applying a raster operation to the source and destination bits as it copies. GDI calls BitBlt whenever an application calls GDI functions such as BitBlt (GDI.34) and PatBlt (GDI.29).

A display driver can provide additional bit-block transfers by providing a StretchBlt function. GDI uses StretchBlt to stretch or compress a block of bits to fit a given rectangle in a bitmap. Stretching and compressing requires either adding or removing bits as defined by a stretching mode. GDI checks the RC_STRETCHBLT value in dpRaster to determine whether the driver provides the StretchBlt function. GDI calls the function whenever an application calls StretchBlt (GDI.35).

If a display driver can carry out bit-block transfers on bitmaps that are larger than 64K, it should set the RC_BITMAP64 value in the dpRaster member. GDI checks this bit to determine whether large bitmaps are permitted. Windows 95 drivers should set this or use the DIB engine which sets this.

A display driver must handle screen-to-screen bit-block transfers and bit-block transfers from a monochrome bitmap to the screen. If using the DIB engine, the minidriver may rely on the DIB engine for bit-block transfers involving just memory bitmaps or from color memory bitmaps to the screen.

Saved Bitmaps

A display driver can permit Windows to temporarily save bitmaps in off-screen video memory by providing the SaveScreenBitmap function. This function allows the driver to take advantage of unused video memory and to speed up drawing operations that require restoring a portion of the screen that was previously overwritten.

GDI checks the RC_SAVEBITMAP value in the dpRaster member to determine whether the driver supports SaveScreenBitmap.