The Windows Palette Manager

What happens if you run a Windows program that uses more colors than the display driver supports? The answer depends on whether there is a palette-based (16-color or 256-color) or a direct color (high color or true color) display driver installed. For direct color displays, things are rather simple because colors are represented in terms of their RGB (red/green/blue) components. This means Windows can just ignore some of the color bits; this happens when displaying a true color image when a high color display is active, for example.

For palette-based displays, things are much more complex. To see why this is so, we need to understand how the Windows palette manager works. The palette manager maintains a system palette that initially contains a set of default colors for the display driver's color depth. These colors are called the system colors and should not be changed by well-behaved Windows programs.

For 16-color display drivers, the system palette contains the 16 default colors shown here:


dark blue

dark gray

bright blue

dark red


bright red


dark green


bright green


light green

light gray



Display drivers that support 256 colors add pale green, pale blue, off white, and medium gray to the system palette, for a total of 20 system colors.

When a program tries to display something in a color that's not in the system palette, the palette manager adds the new color to the system palette if there is room for the new color. For 16-color display drivers, the system palette already contains 16 colors, so there never will be room for a new color. For 256-color display drivers, the system palette initially has room for 236 user-definable colors (256 colors less the 20 system colors). In both cases, the palette manager matches requests for new colors to the closest color in the system palette once the system palette is full.

Another time the palette manager comes into play is when two or more programs (or two or more instances of the same program) are active. If these applications use nothing but the Windows system colors, there's no problem because there will be no color conflicts between them. The same will generally be true when using high color and true color display drivers because they are not palette-based. Consider the case, however, of using a 256-color display driver with two programs that each use their own distinct set of 256 colors. A simple example would be running more than one instance of a PCX file viewer, where one instance displayed one PCX file and a second instance displayed another PCX file with a different palette. A color conflict will occur because the display driver can only display 256 simultaneous colors and the two PCX files could require up to 512 different colors. In this case, the palette manager gives color priority to the active (top-level) window and maps its colors into the system palette. Colors in other windows are first mapped to unused entries in the system palette, then once the system palette becomes full, to the closest colors in the new system palette. This has the overall effect of giving the active window its first choice of colors, while still preserving a reasonable appearance for other windows.

<< Prev

Next >>

Fastgraph Home Page


copyright 2001 Ted Gruber Software, Inc.