Color

The colors that are available for use by the X client is controlled by the X server implementation, and usually depends on the underlying hardware. The X protocol provides a mechanism for converting color names into entries in a colormap. Each pixel is just an entry into the colormap.

Visuals

The characteristics of the colormap are defined by the type of visual that is being used.  Visuals can be either Read-Only, or Read/Write. There are three types of colormaps, thus resulting in six visuals. The six visuals are:
 
Colormap Type  Read/Write  Read-Only
Monochrome/Gray  GrayScale StaticGray
Single Index for RGB PseudoColor  StaticColor
Multiple indices for RGB DirectColor  TrueColor

The pixel value is used for the index into the colormap on the 4 visuals that support color. A Single index means that the pixel value is the index into a single Colormap that contains the R,G, and B values for a color. Multiple indices means that the Pixel value is broken down into three parts, each of which is an index into the colormap for either R,G, or B (there are three colormaps in this case).

Typically, single index colormaps support either 4 or 8 planes, while the multiple index colormaps support 24 planes.

On Read-Only colormaps, the X server will return a best match when a color is requested by an X client. On Read/Write colormaps, a new entry is created with the exact color requested. When the colormap gets full, all other requests will fail, unless they are an exact match with an existing entry.

RGB Database

The X Server uses the RGB database to convert from a color name to RGB values. This database usually lives in /usr/X11R6/lib/X11 and is called rgb.txt.

Sometimes, the X server may read a version that has been compiled with dbm(1).