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