The RGB Color Record
The RGB Color Record
The RGB color record consists of three 16-bit values, one each for red,
green, and blue.
Your application can specify RGB colors, and the graphics system will find the
closest matching color on the target hardware. To draw a yellow line, for
example, you might set the foreground pen to an RGB color in which the red and
green values are high and the blue value is low, such as (to take the brightest
example) $FFFF FFFF 0000.
If the red, green, and blue values are equal, the resulting color is black (if
they are 0), white (if they are at or close to $FFFF), or gray (if they are in
between).
Color Collections
RGB color records are included in two forms of collective color sets: the color
table and the palette. Each associates additional information with the RGB color
record.
A color table consists of a header containing flags and information such as
the size of the table, and a number of RGB color records, each record preceded
by a value. The RGB color plus a value is defined as a color specification record.
The value has one of two uses, depending on a header flag. If the color table
belongs to a pixel map, the value is the color's index.
The other form in which colors are usefully gathered is the palette, a color
collection of colors that can be used by a window. A palette comprises a header
and a collection of color information records, which contain RGB colors with
information about how the colors are to be used and how closely the graphics
system must match them.
The Palette Manager manipulates both color tables and palettes, and it has
routines for con-verting one into the other. By using the Palette Manager,
your application can exercise exquisite control of color allocation. For
example, you can specify the usage information in a palette such that a selected
set of colors appears if the window is displayed on an 8-bit-deep screen, and
another set of colors appears if the window is displayed on a 4-bit-deep
screen. The Palette Manager has sets of default colors for different pixel
depths, so that a screen will return to a well-balanced state after gaudy
applications terminate. See the Palette Manager for more information on
creating and manipulating palettes.