; docformat = 'rst' ;+ ; Converts color indices to RGB coordinates. 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. ; ; :Categories: ; direct graphics ; ; :Examples: ; For example:: ; ; IDL> print, vis_index2rgb('ffff00'x) ; 0 255 255 ; ; Multiple colors can be converted at once:: ; ; IDL> colors = ['ffff00'x, 'ffffff'x, '0000ff'x, 'ff00ff'x] ; IDL> rgbColors = vis_index2rgb(colors) ; IDL> print, rgbColors ; 0 255 255 255 ; 255 255 0 0 ; 255 255 0 255 ; IDL> tvlct, rgbColors ; ; :Returns: ; bytarr(3) or bytarr(n, 3) ; ; :Params: ; indices : in, required, type=long or lonarr(n) ; indices representing either a color or n colors ;- function vis_index2rgb, indices compile_opt strictarr r = indices and 255B g = ishft(indices, -8) and 255B b = ishft(indices, -16) and 255B return, byte(reform([[r], [g], [b]])) end ; main-level example program print, vis_index2rgb('ffff00'x) colors = ['ffff00'x, 'ffffff'x, '0000ff'x, 'ff00ff'x] rgbColors = vis_index2rgb(colors) print, rgbColors tvlct, rgbColors end