pro MakeRGB ;+ ; NAME: ; MakeRGB ; PURPOSE: ; Uses the standard 256-color IDL tables to patch together a 256-color ; table ; CATEGORY: ; CALLING SEQUENCE: ; INPUTS: ; OPTIONAL INPUT PARAMETERS: ; OUTPUTS: ; OPTIONAL OUTPUT PARAMETERS: ; CALLS: ; IsDisplay ; INCLUDE: ; @skycolors.pro ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ;- on_error, 2 @skycolors.pro ; Dummy comment for Linux dname = !d.name ; Save current device set_plot, !TheTerminal ; Set terminal device ; On the VAX, !d.n_colors is initially set to 256, but drops to 209 when the first ; window is opened. The call to twin is a kludge to get the lower number of ; actually available colors. On the PC this is not necessary: in 256 color mode ; !d.n_colors is immediately set to 236. In 24-bit color mode the system does not ; reserve any colors for itself and !d.n_colors=2^24. if IsDisplay() then begin twin, /show, xsize=5, ysize=5 TotalColors = !d.n_colors twin, /del endif else $ TotalColors = !d.n_colors ; For the time being, stick to 256 colors max TotalColors = TotalColors < 256 ncolors = 2+2+2+2+2+2+4+5*256+256 ; At most needed rr = bytarr(ncolors, /nozero) gg = bytarr(ncolors, /nozero) bb = bytarr(ncolors, /nozero) ; Define a couple of colors; assign two consecutive indices to each color n = 0L FirstColor = n Black = [n,n+1] ; Black rr[Black] = 0 gg[Black] = 0 bb[Black] = 0 n = n+2 ; # colors used = next free index White = [n,n+1] ; White rr[White] = 255 gg[White] = 255 bb[White] = 255 n = n+2 Purple = [n,n+1] rr[Purple] = 252 ; purple (2 colors) gg[Purple] = 76 bb[Purple] = 193 n = n+2 Red = [n,n+1] rr[Red] = 255 ; red (2 colors) gg[Red] = 0 bb[Red] = 0 n = n+2 Green = [n,n+1] rr[Green] = 102 ; 0 ; green (2 colors) gg[Green] = 162 ; 255 bb[Green] = 0 ; 10 n = n+2 Blue = [n,n+1] rr[Blue] = 0 ; blue (2 colors) gg[Blue] = 0 bb[Blue] = 255 n = n+2 ; Read the bitmap earth.bmp. It contains only 4 different colors. ;map = read_bmp( filepath(root=getenv('SYS'),'earthxxx.bmp'),r,g,b) ;write_bmp, filepath(root=getenv('SYS'),'earthxxxtmp.bmp'), $ ; n+read_bmp(filepath(root=getenv('SYS'),'earthxxxtmp.bmp'),r,g,b), $ ; shift(r,n),shift(g,n),shift(b,n) Earth = n+lindgen(4) rr[Earth] = r[0:3] ; 4 colors from Earth gg[Earth] = g[0:3] bb[Earth] = b[0:3] Earth = [Earth[0],Earth[3]] n = n+4 ; Establish four ranges of color indices by extracting from the default IDL 256-color tables ; greyish, blueish, yellowish, reddish, greenish ; The number of colors extracted using tvlct will be ncolors, but never more than 256. ;istart = 60 ; extract starting at istart ;istep = 4 ; extract every istep color ;istart = 100 ;istep = 3 ;istart = 159 ;istep = 2 ;i = 80+3*indgen(40) ;i = 80+4*indgen(40) k = ((TotalColors-n)/5) < 256 ; Maximum # free indices needed for each color range ; Grey, blue, yellow, red, green nTables = n_elements(iTables) pTables = lonarr(nTables,/nozero) eTables = lonarr(nTables,/nozero) for iT=0,nTables-1 do begin loadct, iTables[iT] tvlct, /get, r,g,b istart = 0 ilen = (n_elements(r)-istart) < k istep = n_elements(r)/ilen i = istart+istep*lindgen(ilen) pTables[iT] = n eTables[iT] = pTables[iT]+ilen-1 rr[pTables[iT]:eTables[iT]] = r[i] gg[pTables[iT]:eTables[iT]] = g[i] bb[pTables[iT]:eTables[iT]] = b[i] n = n+ilen endfor LastColor = n-1 ; Append the color table that is used to set up the rgbo ; array for Voxel_Proj ;loadct, 33 ; Blue-red loadct, 4 ; Blue/green/red/yellow tvlct, /get, r, g, b pRgbo = n eRgbo = n+n_elements(r)-1 rr[pRgbo:eRgbo] = r ; Append predefined 256-color table gg[pRgbo:eRgbo] = g bb[pRgbo:eRgbo] = b rr = rr[0:eRgbo] gg = gg[0:eRgbo] bb = bb[0:eRgbo] ; Write to file openw, /get_lun, iu, filepath(root=getenv('SYS'),'skyrgb.txt') printf, iu, [transpose(rr),transpose(gg),transpose(bb)] free_lun, iu openw, /get_lun, iu, filepath(root=getenv('SYS'),'skyinfo.txt') printf, iu, 'TotColors:', TotalColors-1,TotalColors-1 printf, iu, cColors, FirstColor,LastColor printf, iu, cBlack , Black printf, iu, cWhite , White printf, iu, cPurple, Purple printf, iu, cRed , Red printf, iu, cGreen , Green printf, iu, cBlue , Blue printf, iu, cEarth , Earth for i=0,nTables-1 do printf, iu, cTables[i],pTables[i],eTables[i] printf, iu, cRgbo , pRgbo,eRgbo free_lun, iu set_plot, dname ; Reestablish the saved device tvlct, rr[0:pRgbo-1], gg[0:pRgbo-1], bb[0:pRgbo-1] ; load the custom table return & end