ColorConverter

The ColorConverter class contains GPE color conversion support. The base ColorConverter class is defined in the Swconvrt.cpp file. This class enables translation among any combination of source and destination surface pixel types at the time that bit blocks are written to the display.

The following table shows the pixel formats for surfaces.

Pixel format Description
PAL_RGB Each pixel is an unsigned long of the form 0x00BBGGRR. This is identical to the PALETTENTRY structure.
PAL_BGR Each pixel is an unsigned long of the form 0x00RRGGBB. This is identical to the RGBQUAD structure.
PAL_MASKED The RGB channels of each pixel are isolated by using bitmasks to identify which specific bits are used for each channel. This is most common for formats of 15 and 16 bpp.
PAL_INDEXED Each pixel contains an index into the current palette for the surface. Palette entries may be 1, 2, 4, or 8 bits long, depending on how many bits per pixel the display uses.

When display drivers call GPE functions with XLATEOBJ pointer parameters, the functions create and initialize ColorConverter objects to handle any color conversion. Alternatively, based on the value of the XLATEOBJ member iUniq, the functions may use a cached ColorConverter object from a previous call.

The ColorConverter object populates two pointers: pLookup and pConverter. If both are NULL, no conversion is required because the source and destination formats are compatible and palettes, if any, are identical.

If pLookup is not NULL, the operation must convert each source pixel to a destination pixel, using the source pixel value as an index into the lookup table. If pConverter is not NULL, it is the address of a function that is called to convert a source pixel to a destination pixel. Use this when source and destination formats are incompatible and the source format is not indexed. At most, either pLookup or pConverter is set to non-NULL. Even if two palettes contain the same entries, the palettes are not considered to be the same if one palette is mutable and the other is not.

Because color conversion is an optional feature, you can reduce or remove part or all of the feature, which enables you to reduce the size of the driver. However, if you choose to alter the conversion feature, be sure to author all bitmaps provided for the platform to a bit depth or palette that is supported by the display driver. The current size of the complete color converter is slightly over 2 kilobytes (KB) when compiled without debugging symbols.

See Also

GPE Base Classes | GPE | GPESurf | Node2D | GPEVGA | Display Drivers | Display Driver Extensions | Display Driver Samples

 Last updated on Tuesday, May 18, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.