Personal IDL library for M. Galloy

single page | use frames     summary     class     fields     routine details     file attributes


includes main-level program


top mg_rgb2index

direct graphics

result = mg_rgb2index(rgb)

Convert RGB coordinates of colors to the decomposed color indices of the colors. Color indices are long integers used in decomposed color in direct graphics where the lowest order byte value is the red value, the next byte is the green value, the next byte is the blue value, and the highest order byte value is unused.

Return value

long or lonarr(n)


rgb in required type=bytarr

either bytarr(3) or bytarr(n, 3) array of RGB coordinates of colors


For example:

IDL> print, mg_rgb2index([255, 255, 255]), format='(Z06)' ; white FFFFFF IDL> print, mg_rgb2index([255, 255, 0]), format='(Z06)' ; yellow 00FFFF IDL> print, mg_rgb2index([0, 0, 255]), format='(Z06)' ; blue FF0000
Multiple RGB triplets can also be passed to MG_RGB2INDEX in an n by 3 byte array:
IDL> mg_loadct, 5, /brewer % LOADCT: Loading table PuBu (Sequential) IDL> tvlct, rgb, /get IDL> print, mg_rgb2index(rgb), format='(8Z)'

File attributes

Modification date: Wed May 14 15:07:15 2014
Lines: 22
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.