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 ; Kling Research and Software ; www.rlkling.com ; LICENSE ; ; This software is OSI Certified Open Source Software. ; OSI Certified is a certification mark of the Open Source Initiative. ; ; Copyright © 1997-2001 Kling Research and Software. ; ; This software is provided "as-is", without any express or ; implied warranty. In no event will the authors be held liable ; for any damages arising from the use of this software. ; ; Permission is granted to anyone to use this software for any ; purpose, including commercial applications, and to alter it and ; redistribute it freely, subject to the following restrictions: ; ; 1. The origin of this software must not be misrepresented; you must ; not claim you wrote the original software. If you use this software ; in a product, an acknowledgment in the product documentation ; would be appreciated, but is not required. ; ; 2. Altered source versions must be plainly marked as such, and must ; not be misrepresented as being the original software. ; ; 3. This notice may not be removed or altered from any source distribution. ; ; For more information on Open Source Software, visit the Open Source ; web site: http://www.opensource.org. ;- 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