;+ ; NAME: ; truecolorconv ; PURPOSE: (one line) ; Convert between 'BBGGRR'XL and [blue,green,red] formulations for truecolor ; DESCRIPTION: ; Convert between 'BBGGRR'XL and [blue,green,red] formulations for truecolor ; CATEGORY: ; util ; CALLING SEQUENCE: ; a = truecolorconv(b) ; INPUTS: ; b - either a 2-D array of longs, where the least significant ; byte is the red shade (0 for black, FF for reddest), ; the next byte is green, and the next byte is blue, OR ; a 3-D array of bytes, where b[0,*,*] is blue, b[1,*,*] is green ; and b[2,*,*] is red ; OPTIONAL INPUT PARAMETERS: ; none ; KEYWORD INPUT PARAMETERS: ; none ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; alternate form (3-D bytes if input is 2-D long, or ; 2-D long if input is 3-D bytes) ; COMMON BLOCKS: ; None ; SIDE EFFECTS: ; RESTRICTIONS: ; None ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2006 Jan 13, by Leslie Young, SwRI ;- function truecolorconv, a bbit = 'FF0000'xl gbit = '00FF00'xl rbit = '0000FF'xl sz = size(a, /dim) if n_elements(sz) eq 3 then begin b = reform(a[2,*,*]) g = reform(a[1,*,*]) r = reform(a[0,*,*]) return, b*'10000'xl + g*'100'xl + r endif else begin aa = bytarr(3,sz[0], sz[1]) aa[2,*,*] = (a and bbit) / '010000'xl aa[1,*,*] = (a and gbit) / '000100'xl aa[0,*,*] = (a and rbit) / '000001'xl return, aa end end