function RGBtoTrue, number ;+ ; ;+ ; NAME: ; RGBtoTrue ; ; PURPOSE: ; Converts a r,g,b value to the true color number ; ; CATEGORY: ; Graphics. ; ; CALLING SEQUENCE: ; true = RGBtoTrue([255,23,12]) ; ; INPUTS: ; r,g,b vector ; ; KEYWORD PARAMETERS: ; None. ; OUTPUTS: ; single long integer ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None.. ; RESTRICTIONS: ; None. ; MODIFICATION HISTORY: ; Derived from David Fanning's color24 function, I just wanted ; a different name. ; Written 2/23/2000 by Ronn Kling ; Ronn Kling Consulting ; www.rlkling.com ;- if n_elements(number) ne 3 then $ message,'You must pass in a three element vector' minNum = min(number, max=maxNum) if minNum lt 0 or maxNum gt 255 then $ message,'Values must be in the range 0 to 255!' base16 = [[1L, 16L],[256L,4096L], [65536L, 1048576L]] trueNum = 0L for j=0,2 do trueNum = trueNum + ((number[j] mod 16) * base16[0,j]) + $ (fix(number[j]/16) * base16[1,j]) return,trueNum end