Objects of the IDLgrPalette class are used to create color lookup tables. Color lookup tables assign individual numerical values to color values; this allows you to specify the color of a graphic object with a single number (a color index) rather than explicitly providing the red, green, and blue color values (an RGB triple). Palettes are most useful when you want data values to correspond to color values. For example, to have a data value of 200 always correspond to a single color. This correspondence is one of the main uses of the Indexed Color Model.

Creating Palette Objects


Specify three vectors representing the red, green, and blue values for the palette when you call the IDLgrPalette::Init method. The values in the red, green, and blue vectors must be integers between zero and 255, and the length of each vector must not exceed 256 elements. For example, the following statements create a palette object that reverses a standard grayscale ramp palette:

rval = (gval = (bval = REVERSE(INDGEN(256))))
myPalette = OBJ_NEW('IDLgrPalette', rval, gval, bval)

Using Palette Objects


Palettes can be associated either with graphics destination objects (windows or printers) or with individual graphic visualization objects:

myWindow->SetProperty, PALETTE=myPalette

or

myImage->SetProperty, PALETTE=myPalette

Note: Palettes associated with graphic visualization objects are only used when the destination object uses an RGB color model; if the destination object uses an indexed color model, the destination object’s palette is always used.

See IDLgrPalette::Init for details on creating palette objects and complete examples.