23.3.4 Creating a Driver Device Context

The DIB driver makes it possible for you to create a DIB device context. To
create the DIB device context, call the CreateDC function, supplying a pointer
to a BITMAPINFO structure:

hdc = CreateDC("DIB", NULL, NULL, lpbi);

You can use the device-context handle returned by the CreateDC function with most GDI functions to modify the bitmap. Concurrently, you can call your own direct-manipulation functions to modify the actual bitmap bits. Any changes made directly to the bitmap bits are reflected in the DIB-driver device context. When you finish modifying the bitmap, you can use the StretchDIBits function to transfer the DIB to the video device context.

The DIB driver can handle 1-bit, 4-bit, or 8-bit DIBs. You can create multiple DIB driver contexts. Note the following limitations:

1.The BITMAPINFO structure must be locked for the life of the device context.

2.The DIB driver handles only the Windows BITMAPINFOHEADER format.

3.The RLE format is not supported.

4.The DIB must use the DIB_RGB_COLORS format. The DIB driver does not support the DIB_PAL_COLORS (palette indexes) format.

You can distribute the DIB driver with applications that run under Windows.