;+ ; ; @file_comments ; The purpose of this function is to convert a RGB color triple ; into the equivalent 24-big long integer. ; This routine was written to be used with routines like COLORS or ; GETCOLOR. ; ; @categories ; Graphics, Color ; ; @param rgb_triple {in}{required} ; A three-element column or row array representing ; a color triple. The values of the elements must be between 0 and 255. ; ; @returns ; a 24-bit long integer that is equivalent the input color. ; The color is described in terms of a hexadecimal number (e.g., FF206A) ; where the left two digits represent the blue color, the ; middle two digits represent the green color, and the right ; two digits represent the red color. ; ; @examples ; To convert the color triple for the color YELLOW, ; (255, 255, 0), to the hexadecimal value '00FFFF'x ; or the decimal number 65535, type: ; ; IDL> color = COLOR24([255, 255, 0]) ; ; ; @history ; Written by: David Fanning, 3 February 96. ; ; @version ; $Id$ ; ;- FUNCTION color24, rgb_triple ; compile_opt idl2, strictarrsubs ; ON_ERROR, 1 IF N_ELEMENTS(rgb_triple) NE 3 THEN $ MESSAGE, 'Argument must be a three-element vector.' IF MAX(rgb_triple) GT 255 OR MIN(rgb_triple) LT 0 THEN $ MESSAGE, 'Argument values must be in range of 0-255' base16 = [[1L, 16L], [256L, 4096L], [65536L, 1048576L]] num24bit = 0L FOR j=0,2 DO num24bit = num24bit + ((rgb_triple[j] MOD 16) * base16[0,j]) + $ (Fix(rgb_triple[j]/16) * base16[1,j]) RETURN, num24bit END