## Color and palette manipulation

The following functions provide full control over colors in the SciTech MGL. SciTech MGL can be running in either color index modes (4 and 8 bits per pixel) or RGB modes (15 bits and above modes, and also RGB 8 bit dithered modes). In color index modes the final color of a pixel is determined by the color lookup table or palette associated with the device context. SciTech MGL provides functions for setting and retrieving color values in the color lookup tables for a device context, and for realizing the color palette on hardware devices.

Note that all device contexts have a color lookup table even for memory device contexts and RGB display device contexts. SciTech MGL will convert color values in 4 and 8 bit memory devices on the fly when BitBlt’ing to any other display device context with 4 bits or more of pixel depth. When doing a BitBlt operation from a color index device context to another color index device context, SciTech MGL will find the closest color if an exact match is not found (this can be turned off for speed though). When doing a BitBlt operation from a color index device context to an RGB device context, the color lookup table in the destination RGB device context will be used to convert the color values.

In order for maximum BitBlt performance when the destination device context is in a color index mode, you must ensure that the color table in the source device context is identical to the color table in the destination device context, in which case no bitmap translation will be performed (i.e.: SciTech MGL determines there is an identity palette mapping). If you know that all BitBlt operations will be perform have identity palettes, you can use the function MGL_checkIdentityPalette to turn on and off this checking code to obtain higher performance. Note however that this does not turn off identity palette checking when BitBlt’ing to a windowed device context under Windows, as this cannot be turned off.

Note also that all SciTech MGL color values are passed to the SciTech MGL as either a color index or a packed RGB value, packed for the correct format expected by the device context. Rather than setting the color value directory, you can use the utility functions MGL_setColorCI and MGL_setColorRGB to set the color given a color index or an RGB color value. When running in RGB modes, the MGL_setColorCI will convert the color index to the proper SciTech MGL color value using the devices color lookup table. When running in color index modes, the MGL_setColorRGB will set the color to the color index with the color palette entry that is the closest to the passed in RGB color value. Functions and macros are provided to pack RGB color values into the proper SciTech MGL color values to be passed the to SciTech MGL. The MGL_pack* family of functions is used to pack color values from 8 bit RGB tuples into the proper SciTech MGL packed RGB color values.

MGL_checkIdentityPalette | MGL_defaultColor
MGL_fadePalette | MGL_getBackColor
MGL_getColor | MGL_getDefaultPalette
MGL_getDitherMode | MGL_getFontAntiAliasPalette
MGL_getGammaRamp | MGL_getPalette
MGL_getPaletteEntry | MGL_getPaletteSize
MGL_getPaletteSnowLevel | MGL_getWriteMode
MGL_haveWidePalette | MGL_mapToPalette
MGL_maxColor | MGL_packColor
MGL_packColorExt | MGL_packColorFast
MGL_packColorFastExt | MGL_realColor
MGL_realizePalette | MGL_rgbColor
MGL_rotatePalette | MGL_setBackColor
MGL_setColor | MGL_setColorCI
MGL_setColorRGB | MGL_setDefaultPalette
MGL_setDitherMode | MGL_setFontAntiAliasPalette
MGL_setGammaRamp | MGL_setPalette
MGL_setPaletteEntry | MGL_setPaletteSnowLevel
MGL_unpackColor | MGL_unpackColorExt
MGL_unpackColorFast | MGL_unpackColorFastExt

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com