Programmer's Reference


Using palettes

A palette defines a mapping from pixel values to colors. Palettes have two common uses:

Common Graphics defines the following palette classes:

CgPalette
Abstract superclass of CgIndexedPalette and CgDirectPalette.

CgIndexedPalette
Defines a pixel-value-to-color mapping as an array of colors, indexed by 0-based pixel values. There is no restriction on the size of the palette (sizes of 2, 16, and 256 are often encountered in standard image formats). Colors are undefined for pixel values not in the palette. A drawable can select a CgIndexedPalette but not a CgDirectPalette.

CgDirectPalette
Defines a pixel-value-to-color mapping that encodes colors directly in pixel values. The palette specifies which bits in a pixel value correspond to each of the RGB primaries. Only the specified bits are used when doing conversions; other bits in a pixel value are ignored. A CgDirectPalette cannot be selected in a drawable. It is used only to specify the pixel-value-to-color mapping of images using direct pixel values. The following sections describe ways of selecting a CgDirectPalette, in order to display images using direct pixel values.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]