The DIB engine supports drawing on 256-color palettized devices. The color data for these devices is specified in a BITMAPINFO structure. The header section of this structure defines the dimensions and color format of the device's DIB. The array of RGBQUAD structures which follows the header corresponds to the device's palette. The members of the BITMAPINFO structure are initialized by a minidriver or display driver when the Enable function is called.
Drivers do not need to initialize their color table. At boot time, GDI calls SetPalette to initialize the device's color table. The display driver should first forward the call to the DIB engine which will store the colors into the color table. After the DIB engine call returns, the driver should set the contents of the color table into the hardware DAC.
To ensure that colors used in background drawing operations match the current system palette, GDI maintains a palette-translation table. When GDI calls a minidriver's SetPaletteTranslate function for a palettized device, you should call the DIB engine's DIB_SetPaletteTranslateExt function to create an inverse translation table that GDI can use for mapping logical color indices to physical color indices. When GDI calls a minidriver's GetPaletteTranslate function for a palettized device, you should call the DIB_GetPaletteTranslateExt function to retrieve a copy of the current translation table. When GDI calls the UpdateColors function, you should call the DIB_UpdateColorsExt function to update the colors in a given window using the colors in the translation table.
When a non-identity palette translation is set, the DIB engine function DIB_SetPaletteTranslateExt sets the PALETTE_XLAT bit in the deFlags field of the DIBENGINE structure. This function clears the PALETTE_XLAT bit when an identity translate is set. Minidrivers and the DIB engine may use this bit to decide whether palette translation is needed or not. When applicable, this bit is set or cleared for palette translation for bitmaps, brushes, pens, foreground color, background color and text color.
If all palette calls from GDI are routed to the DIB engine, all that is needed to check for palette translation in a function call such as BitBlt is to test the PALETTE_XLAT bit in the deFlags of the PDEVICE parameter. For functions that take one PDEVICE and the PALETTE_XLAT bit is set, the call should be routed to the DIB Engine. For functions that take two PDEVICE structures, the minidriver should check the PALETTE_XLAT bit in both PDEVICE structures. If the bit is set in one, but not both, the call must be routed to the DIB engine. If the bit is set in both PDEVICE structures and the ROP code is SRCCOPY, the operation is a screen-to-screen draw and the minidriver should handle it; no palette translation needs to be done. Otherwise, the call should be routed to the DIB engine because it may need to translate the colors in a brush.
DIB_SetPaletteExt, DIB_GetPaletteExt, DIB_SetPaletteTranslateExt, DIB_GetPaletteTranslateExt, DIB_UpdateColorsExt