Color and colormaps

A color is a triple of Red, Green, Blue values. Each pixel, or point, in a window or pixmap may be a different color. On each hardware platforms, there will be a restriction on the number of colors that may be displayed in a window at a time, and also a limitation on the number of different colors that are possible at all. For example, many screens are capable of showing approximately 16 million colors (256 different shades each of red, green, and blue), but can only show 256 colors at one time. This means that pixel values, the numbers assigned to each pixel, will be between 0 and 255. Each window, therefore, must have a way to know what color is associated with each pixel value. This is what a colormap does: it maps from pixel values to actual colors.

Notice that a colormap is associated with each window, but not with pixmaps. The pixel values in a pixmap are uninterpreted until the pixmap is copied to a window. So a pixmap copied into two different windows may appear in different colors if those windows have different colormaps.