Next Prev Up

# 9.1 Colormaps and Colors

In X, a color is defined by a set of three numeric values, representing intensities of red, green, and blue. Red, green, and blue are referred to as the primary hues. A colormap is a list of colors, each indexed by an integer pixel value. Each entry in a colormap is called a color cell. Raster graphics displays store pixel values in a special screen hardware memory. As the screen hardware scans this memory, it reads each pixel value, looks up the color in the corresponding cell of a colormap, and displays the color on its screen.

The colormap abstraction applies to all classes of visual types supported by X, including those for screens which are actually monochrome. For example, :gray-scale screens use colormaps in which colors actually specify the monochrome intensity. A typical black-and-white monochrome display has a :static-gray screen with a two-cell colormap.

The following list describes how pixel values and colormaps are handled for each visual class.

:direct-color
  A pixel value is decomposed into separate red, green, and blue subfields. Each subfield indexes a separate colormap. Entries in all colormaps can be changed.
:gray-scale
  A pixel value indexes a single colormap that contains monochrome intensities. Colormap entries can be changed.
:pseudo-color
  A pixel value indexes a single colormap that contains color intensities. Colormap entries can be changed.
:static-color
  Same as :pseudo-color, except that the colormap entries are predefined by the hardware and cannot be changed.
:static-gray
  Same as :gray-scale, except that the colormap entries are predefined by the hardware and cannot be changed.
:true-color
  Same as :direct-color, except that the colormap entries are predefined by the hardware and cannot be changed. Typically, each of the red, green, and blue colormaps provides a (near) linear ramp of intensity.

CLX provides functions to create colormaps, access and modify colors and color cells, and install colormaps in screen hardware.

Next Prev Up

© 1988, 1989 Texas Instruments Incorporated
Conversion to HTML made by Gilbert Baumann.
Last build: Tue Dec 16 23:30:42 1997