IDL determines colors to display differently based on whether the destination object uses an Indexed or RGB color model, and on whether the physical destination device supports an Indexed or RGB color model.

Indexed Color Model


If the destination object uses an Indexed color model, the color displayed is calculated from the value specified by the object’s COLOR property as follows:

If a Color Index is Specified

  • If the physical device uses an Indexed color model, the specified color index is used as an index into the physical device’s lookup table. (Remember that the physical device’s color lookup table is loaded via the PALETTE keyword to the destination object.)
  • If the physical device uses an RGB color model, the specified color index is used as an index into the destination object’s palette. The RGB triple stored at the index’s location in the palette is used as the physical device’s color value.

If an RGB Triple is Specified

  • If the physical device uses an Indexed color model, the RGB triple is mapped to the index of the nearest match in the device’s color lookup table.
  • If the physical device uses an RGB color model, the RGB triple is passed directly to the device.

RGB Color Model


If the destination object uses an RGB color model, the color displayed is calculated from the value specified by the object’s COLOR property as follows:

If a Color Index is Specified

If the graphic object for which the color is being determined has a palette associated with it, the RGB triple at that palette’s color index is retrieved. Otherwise, the RGB triple at the specified index in the destination object’s palette is retrieved.

  • If the physical device uses an Indexed color model, the RGB triple retrieved is mapped to the index of the nearest match in the device’s color lookup table.
  • If the physical device uses an RGB color model, the RGB triple retrieved is passed directly to the device.

If an RGB Triple is Specified

  • If the physical device uses an Indexed color model, the RGB triple is mapped to the index of the nearest match in the device’s color lookup table.
  • If the physical device uses an RGB color model, the RGB triple is passed directly to the device.

If the RGB color model is used, the palette associated with a destination object does not necessarily have a one-to-one mapping to the hardware color lookup table for the device. For instance, the destination object may have a grayscale ramp loaded as a palette, but the hardware color lookup table for the device may be loaded with an even sampling of colors from the RGB color cube. When a user requests that a graphical object be rendered in a particular color, that object will appear in the nearest approximation to that color that the device can supply.