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