1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; |
---|
5 | ; @categories |
---|
6 | ; |
---|
7 | ; @param TABLE |
---|
8 | ; |
---|
9 | ; @restrictions |
---|
10 | ; |
---|
11 | ; @examples |
---|
12 | ; |
---|
13 | ; @history |
---|
14 | ; |
---|
15 | ; @version |
---|
16 | ; $Id$ |
---|
17 | ; |
---|
18 | ;- |
---|
19 | PRO format_colortable_hexa, table |
---|
20 | ; |
---|
21 | compile_opt idl2, strictarrsubs |
---|
22 | ; |
---|
23 | |
---|
24 | tvlct, r, g, b, /get |
---|
25 | |
---|
26 | z = strarr(256) |
---|
27 | y = strarr(256) |
---|
28 | for k=0,255 do z[k]='00'+strtrim(string(r[k], format = '(Z)'),2) |
---|
29 | for k=0,255 do y[k]=y[k]+strmid(z[k],strlen(z[k])-2,2) |
---|
30 | |
---|
31 | for k=0,255 do z[k]='00'+strtrim(string(g[k], format = '(Z)'),2) |
---|
32 | for k=0,255 do y[k]=y[k]+strmid(z[k],strlen(z[k])-2,2) |
---|
33 | |
---|
34 | for k=0,255 do z[k]='00'+strtrim(string(b[k], format = '(Z)'),2) |
---|
35 | for k=0,255 do y[k]=y[k]+strmid(z[k],strlen(z[k])-2,2) |
---|
36 | |
---|
37 | table = strlowcase(y) |
---|
38 | |
---|
39 | END |
---|
40 | ; |
---|
41 | ;+ |
---|
42 | ; |
---|
43 | ; @file_comments |
---|
44 | ; Build a bloc of colortable |
---|
45 | ; |
---|
46 | ; @categories |
---|
47 | ; |
---|
48 | ; @param TABLEOUT |
---|
49 | ; |
---|
50 | ; @restrictions |
---|
51 | ; |
---|
52 | ; @examples |
---|
53 | ; |
---|
54 | ; @history |
---|
55 | ; |
---|
56 | ; @version |
---|
57 | ; $Id$ |
---|
58 | ; |
---|
59 | ;- |
---|
60 | PRO build_table, tableout |
---|
61 | ; |
---|
62 | compile_opt idl2, strictarrsubs |
---|
63 | ; |
---|
64 | |
---|
65 | format_colortable_hexa, table |
---|
66 | |
---|
67 | tableout = strarr(25) |
---|
68 | |
---|
69 | tableout[0] = '/COLORTAB < ' |
---|
70 | FOR k = 0, 8 DO tableout[0] = tableout[0]+table[k]+' ' |
---|
71 | FOR i = 1, 22 DO BEGIN |
---|
72 | FOR k = 11*i-2, 11*i+8 DO tableout[i] = tableout[i]+table[k]+' ' |
---|
73 | ENDFOR |
---|
74 | FOR k = 251, 255 DO tableout[i] = tableout[i]+table[k]+' ' |
---|
75 | tableout[i] = tableout[i]+'> def' |
---|
76 | |
---|
77 | END |
---|
78 | ; |
---|
79 | ;+ |
---|
80 | ; |
---|
81 | ; @file_comments |
---|
82 | ; Modify colors of a postscript file |
---|
83 | ; |
---|
84 | ; @categories |
---|
85 | ; |
---|
86 | ; @param N1 {in}{required} |
---|
87 | ; Number of elements in the first dimension |
---|
88 | ; |
---|
89 | ; @param N2 {in}{required} |
---|
90 | ; Number of elements in the second dimension |
---|
91 | ; |
---|
92 | ; @param FILE |
---|
93 | ; A scalar of string type, the name of the ".pro" file to be tested |
---|
94 | ; if necessary, the input name is completed with '.pro' and its path |
---|
95 | ; found in !path |
---|
96 | ; |
---|
97 | ; @keyword PALIT1 |
---|
98 | ; |
---|
99 | ; @keyword PALIT2 |
---|
100 | ; |
---|
101 | ; @restrictions |
---|
102 | ; |
---|
103 | ; @examples |
---|
104 | ; |
---|
105 | ; @history |
---|
106 | ; G. Roullet 1999 |
---|
107 | ; |
---|
108 | ; @version |
---|
109 | ; $Id$ |
---|
110 | ; |
---|
111 | ;- |
---|
112 | PRO chcolps, n1, n2, file, PALIT1=palit1, PALIT2=palit2 |
---|
113 | ; |
---|
114 | compile_opt idl2, strictarrsubs |
---|
115 | ; |
---|
116 | ; recuperate palettes |
---|
117 | ; |
---|
118 | lct, n1 |
---|
119 | IF keyword_set(palit1) THEN palit, palit1 |
---|
120 | tvlct, red, green, blue, /get |
---|
121 | |
---|
122 | lct, n2 |
---|
123 | IF keyword_set(palit2) THEN palit, palit2 |
---|
124 | tvlct, red1, green1, blue1, /get |
---|
125 | ; |
---|
126 | filein = file |
---|
127 | fileout = file+'.new' |
---|
128 | |
---|
129 | openr, numin, filein, /get_lun |
---|
130 | openw, numout, fileout, /get_lun |
---|
131 | ligne = '' |
---|
132 | nl = 0 |
---|
133 | colortab = 0 |
---|
134 | ; |
---|
135 | ; Scan le fichier |
---|
136 | ; |
---|
137 | WHILE NOT(eof(numin)) DO BEGIN |
---|
138 | readf, numin, ligne, format = '(A)' |
---|
139 | nl = nl+1 |
---|
140 | ; |
---|
141 | ; Replace setrgbcolor statements |
---|
142 | ; |
---|
143 | pos = strpos(ligne, 'setrgbcolor') |
---|
144 | IF pos NE -1 THEN BEGIN |
---|
145 | r = round(float(strmid(ligne, pos-18, 6))*255) |
---|
146 | g = round(float(strmid(ligne, pos-12, 6))*255) |
---|
147 | b = round(float(strmid(ligne, pos-6, 6))*255) |
---|
148 | ind = where(r EQ red AND g EQ green AND b EQ blue) |
---|
149 | ind = ind[0] |
---|
150 | IF ind[0] NE -1 THEN BEGIN |
---|
151 | r1 = red1[ind]/255. |
---|
152 | g1 = green1[ind]/255. |
---|
153 | b1 = blue1[ind]/255. |
---|
154 | color = string(r1, g1, b1, format = '(3(F5.3,:,X))') |
---|
155 | strput, ligne, color, pos-18 |
---|
156 | ENDIF ELSE BEGIN |
---|
157 | ; ras = report('erreur ligne :' + string(nl)) |
---|
158 | dist = abs(r-red)+abs(g-green)+abs(b-blue) |
---|
159 | ind = (where(dist EQ min(dist)))[0] |
---|
160 | ind = ind[0] |
---|
161 | ; ras = report( $ |
---|
162 | ; ['I found ' + string(long([r, g, b])), $ |
---|
163 | ; 'I replace it by ' + string([red[ind], green[ind], blue[ind]])]) |
---|
164 | r1 = red1[ind]/255. |
---|
165 | g1 = green1[ind]/255. |
---|
166 | b1 = blue1[ind]/255. |
---|
167 | color = string(r1, g1, b1, format = '(3(F5.3,:,X))') |
---|
168 | strput, ligne, color, pos-18 |
---|
169 | ENDELSE |
---|
170 | ENDIF |
---|
171 | ; |
---|
172 | ; Replace COLORTAB |
---|
173 | ; |
---|
174 | pos = strpos(ligne, '/COLORTAB') |
---|
175 | IF pos NE -1 THEN BEGIN |
---|
176 | build_table, table |
---|
177 | n = 0 |
---|
178 | colortab = 1 |
---|
179 | ENDIF |
---|
180 | |
---|
181 | IF colortab THEN BEGIN |
---|
182 | ligne = table[n] |
---|
183 | n = n+1 |
---|
184 | IF n EQ 24 THEN colortab = 0 |
---|
185 | ENDIF |
---|
186 | ; |
---|
187 | ; write output file |
---|
188 | ; |
---|
189 | printf, numout, ligne, format = '(A)' |
---|
190 | ENDWHILE |
---|
191 | close, numin |
---|
192 | close, numout |
---|
193 | free_lun, numin |
---|
194 | free_lun, numout |
---|
195 | |
---|
196 | spawn, 'gs '+fileout |
---|
197 | |
---|
198 | END |
---|