19.1 What a Color Palette Does

Many color graphics adapters (screens) are capable of displaying a wide range of colors. In most cases, however, the number of colors that the screen can render at any given time is more limited. For example, a screen that is potentially able to produce 26,000 different colors may be able to show only 256 of those colors simultaneously, because of hardware limitations. When such a limitation exists, the device often maintains a palette of colors. When an application requests a color that is not currently displayed, the device adds the requested color to the palette. However, when the number of requested colors exceeds the maximum number for the device, it maps the requested color to an existing color; this means the colors displayed are different from the colors requested. When this happens, the system attempts to replace requested colors with similar existing colors, so the difference between the requested colors and the displayed colors is often small.

Windows color palettes provide a buffer between a color-intensive application and the system. A color palette allows an application to use as many colors as are necessary without interfering with colors displayed by other windows. When a window uses a color palette and has the input focus, Windows ensures that it will display all the colors it requests, up to the maximum number available simultaneously on the screen, and displays additional colors by matching them to available colors. In addition, Windows matches the colors requested by inactive windows as closely as possible to the available colors. This reduces undesirable changes in what colors are displayed in inactive windows.