Your application loads the DIB driver by passing the DIB driver name and a BITMAPINFO structure containing the DIB bits to CreateDC. For example, the following statement creates a DIB display context that represents the packed-DIB described by the BITMAPINFO data structure bi:
hdc = CreateDC ("DIB", NULL, NULL, (LPSTR)&bi);
When working with this device context, you must observe the following rules:
If the last parameter of CreateDC is NULL, the display context is associated with a 0-by-0 8-bit DIB. Any attempt to draw with it will fail.
The BITMAPINFO structure must remain locked for the life of the device context.
The DIB driver supports 1-bit, 4-bit, or 8-bit DIB bitmaps. The RLE format is not supported.
The DIB driver supports only Windows 3.0 format DIB headers. The OS/2 BITMAPCOREHEADER format is not supported.
Multiple DIB driver display contexts can be active.
DIBs reside in the memory-based image buffer in the CF_DIB (packed-DIB) format.
The DIB driver expects the RGBQUAD data structure for color matching. (It dos not use palette indexes.)
The following code fragment uses the DIB driver to draw a circle in a DIB copied from the Clipboard:
if (IsClipboardFormatAvailable(CF_DIB) && OpenClipboard())
{
HANDLE hdib;
HDC hdc;
// Get the DIB from the Clipboard
hdib = GetClipboardData (CF_DIB);
// Create a DIB driver hdc on the DIB surface
hdc = CreateDC ("DIB", NULL, NULL,
(LPSTR)(LPBITMAPINFO)GlobalLock(hdib));
// Draw a circle in the DIB
Ellipse (hdc, 0, 0, 100, 100);
// Delete the DIB driver HDC now that you are done with it
DeleteDC (hdc);
// Unlock the DIB
GlobalUnlock (hdib);
// Release the Clipboard
CloseClipboard ();
}