Appendix F


© 1995, 1996, 1997 Gregg M. Townsend, Ralph E. Griswold, and Clinton L. Jeffery

Palettes

Palettes are predefined sets of colors that are used with DrawImage(). Palettes also can be used to limit the colors used by ReadImage().

This appendix documents the contents of Icon's palettes and serves as a reference for the programmer. It is hard, though, to understand a palette just by reading about it. The program palette, which displays and labels the colors of the palette, provides a clearer introduction.

Grayscale Palettes

The g16 palette, shown below, provides 16 shades of gray specified by the hexadecimal characters 0123456789ABCDEF, with 0 being black and F being white in accordance with the usual conventions of image processing.



Actually, g16 is just one member of a family of palettes named g2 through g64, each providing the corresponding number of equally spaced shades from black to white. Each gn palette uses the first n characters of this list:
   0123456789ABCXYZabcxyz{}
In every case 0 is black and the rightmost character is white.

For palettes with more than 64 entries, it becomes more difficult and eventually impossible to stay within the printable characters. The remaining grayscale palettes, g65 through g256, use the first n characters of &cset instead of the list above.

The c1 Palette

The palette c1 is designed for constructing color images by hand. It is defined using the Icon color-naming system by the table below.

hue deep dark medium light pale weak
black 0 gray 1 2 3 4 5 white 6 brown ! p ? C 9 red n N A a # @ orange o O B b $ % red-yellow p P C c & | yellow q Q D d , . yellow-green r R E e ; : green s S F f + - cyan-green t T G g * / cyan u U H h ` ' blue-cyan v V I i < > blue w W J j ( ) purple x X K k [ ] magenta y Y L l { } magenta-red z Z M m ^ = pink 7 violet 8
Note that in the Icon color naming system, "dark brown" and "light brown" are the same as two shades of red-yellow.

Uniform Color Palettes

Programs that compute images can more easily use a palette having RGB colors that are in some sense "equally spaced". The c3, c4, c5, and c6 palettes are designed with this in mind, and the c2 palette can also be considered part of this family. The larger palettes allow better color selection and subtler shadings but use up more of the limited number of simultaneous colors.

For any of these cn palettes, the palette provides n levels of each RGB primary color; letting m = n - 1, these levels range from 0 (off) to m (full on). The palette also provides all the colors that can be obtained by mixing different levels of the primaries in any combination. Mixing equal levels produces black (0,0,0), white (m,m,m), or a shade of gray. Mixing unequal levels produces colors.

Each cn palette also provides (n - 1)^2 additional shades of gray to allow better rendering of monochrome images. n - 1 intermediate shades are added in each interval created by the original n regular achromatic entries, giving a total of n^2 - n + 1 grayscale entries.

The lists below specify the characters used by each palette. The n ^3 regular entries are ordered from (0,0,0) to (m,m,m), black to white, with the blue component varying most rapidly and the red component varying most slowly. These are followed in the right column by the additional shades of gray from darkest to lightest.
c2: kbgcrmyw                              x
c3: @ABCDEFGHIJKLMNOPQRSTUVWXYZ           abcd
c4: 0123456789ABC ... XYZabc ... wxyz{}   $%&*-/?@
c5: \000\001 ... yz{|                     }~\d\200\201 ... \214
c6: \000\001 ... \327                     \330\331 ... \360
For example, the regular portion of the c3 palette is interpreted this way:

char. r g b char. r g b char. r g b
@ 0 0 0 I 1 0 0 R 2 0 0 A 0 0 1 J 1 0 1 S 2 0 1 B 0 0 2 K 1 0 2 T 2 0 2 C 0 1 0 L 1 1 0 U 2 1 0 D 0 1 1 M 1 1 1 V 2 1 1 E 0 1 2 N 1 1 2 W 2 1 2 F 0 2 0 O 1 2 0 X 2 2 0 G 0 2 1 P 1 2 1 Y 2 2 1 H 0 2 2 Q 1 2 2 Z 2 2 2
The complete set of grayscale entries in c3, merging regular and extra entries, is @abMcdZ (from black to white).

The sizes of c5 and c6 require that they include some nonprinting characters, so they are better suited for computed images than direct specification.

Back to Contents