1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Radiance picture to PostScript file translator -- one way! |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
< |
#ifdef MSDOS |
10 |
< |
#include <fcntl.h> |
11 |
< |
#endif |
9 |
> |
#include <string.h> |
10 |
> |
#include <math.h> |
11 |
> |
#include <ctype.h> |
12 |
> |
|
13 |
> |
#include "platform.h" |
14 |
|
#include "color.h" |
15 |
+ |
#include "resolu.h" |
16 |
|
|
17 |
+ |
#define UPPER(c) ((c)&~0x20) /* ASCII trick */ |
18 |
+ |
|
19 |
+ |
#define CODE6GAM 1.47 /* gamma for 6-bit codes */ |
20 |
+ |
#define DEFGGAM 1.0 /* greyscale device gamma */ |
21 |
+ |
#define DEFCGAM 1.8 /* color device gamma */ |
22 |
+ |
|
23 |
|
#define GRY -1 /* artificial index for grey */ |
24 |
|
|
25 |
< |
#define HMARGIN (.5*72) /* horizontal margin */ |
26 |
< |
#define VMARGIN (.5*72) /* vertical margin */ |
27 |
< |
#define PWIDTH (8.5*72-2*HMARGIN) /* width of device */ |
28 |
< |
#define PHEIGHT (11*72-2*VMARGIN) /* height of device */ |
25 |
> |
#define DEFMARG 0.5 /* default margin (inches) */ |
26 |
> |
#define DEFWIDTH 8.5 /* default page width */ |
27 |
> |
#define DEFHEIGHT 11 /* default page height */ |
28 |
> |
#define HMARGIN (hmarg*72) /* horizontal margin */ |
29 |
> |
#define VMARGIN (vmarg*72) /* vertical margin */ |
30 |
> |
#define PWIDTH (width*72-2*HMARGIN) /* width of device */ |
31 |
> |
#define PHEIGHT (height*72-2*VMARGIN) /* height of device */ |
32 |
|
|
33 |
|
#define RUNCHR '*' /* character to start rle */ |
34 |
|
#define MINRUN 4 /* minimum run-length */ |
41 |
|
int wrongformat = 0; /* input in wrong format? */ |
42 |
|
double pixaspect = 1.0; /* pixel aspect ratio */ |
43 |
|
|
44 |
< |
int docolor = 0; /* produce color image? */ |
44 |
> |
double devgam = 0.; /* device gamma response */ |
45 |
> |
double hmarg = DEFMARG, |
46 |
> |
vmarg = DEFMARG; /* horizontal and vertical margins */ |
47 |
> |
double width = DEFWIDTH, |
48 |
> |
height = DEFHEIGHT; /* default paper width and height */ |
49 |
> |
double dpi = 0; /* print density (0 if unknown) */ |
50 |
> |
int docolor = 1; /* produce color image? */ |
51 |
|
int bradj = 0; /* brightness adjustment */ |
52 |
|
int ncopies = 1; /* number of copies */ |
53 |
|
|
54 |
+ |
extern int Aputprim(), Bputprim(), Cputprim(); |
55 |
+ |
|
56 |
+ |
int (*putprim)() = Aputprim; /* function for writing scanline */ |
57 |
+ |
|
58 |
|
char *progname; |
59 |
|
|
60 |
< |
int xmax, ymax; |
60 |
> |
int xmax, ymax; /* input image dimensions */ |
61 |
|
|
62 |
< |
extern char *malloc(); |
62 |
> |
extern double unit2inch(); |
63 |
|
|
64 |
+ |
static gethfunc headline; |
65 |
|
|
66 |
< |
headline(s) /* check header line */ |
67 |
< |
char *s; |
66 |
> |
|
67 |
> |
static int |
68 |
> |
headline( /* check header line */ |
69 |
> |
char *s, |
70 |
> |
void *p |
71 |
> |
) |
72 |
|
{ |
73 |
|
char fmt[32]; |
74 |
|
|
77 |
|
wrongformat = strcmp(fmt, COLRFMT); |
78 |
|
} else if (isaspect(s)) |
79 |
|
pixaspect *= aspectval(s); |
80 |
+ |
return(0); |
81 |
|
} |
82 |
|
|
83 |
|
|
86 |
|
char *argv[]; |
87 |
|
{ |
88 |
|
int i; |
89 |
+ |
double d; |
90 |
|
|
91 |
|
progname = argv[0]; |
92 |
|
|
93 |
|
for (i = 1; i < argc; i++) |
94 |
|
if (argv[i][0] == '-') |
95 |
|
switch (argv[i][1]) { |
96 |
+ |
case 'b': /* produce b&w PostScript */ |
97 |
+ |
docolor = 0; |
98 |
+ |
break; |
99 |
|
case 'c': /* produce color PostScript */ |
100 |
< |
docolor++; |
100 |
> |
docolor = 1; |
101 |
|
break; |
102 |
+ |
case 'A': /* standard ASCII encoding */ |
103 |
+ |
putprim = Aputprim; |
104 |
+ |
break; |
105 |
+ |
case 'B': /* standard binary encoding */ |
106 |
+ |
putprim = Bputprim; |
107 |
+ |
break; |
108 |
+ |
case 'C': /* compressed ASCII encoding */ |
109 |
+ |
putprim = Cputprim; |
110 |
+ |
break; |
111 |
+ |
case 'd': /* print density */ |
112 |
+ |
dpi = atof(argv[++i]); |
113 |
+ |
break; |
114 |
+ |
case 'g': /* device gamma adjustment */ |
115 |
+ |
devgam = atof(argv[++i]); |
116 |
+ |
break; |
117 |
+ |
case 'p': /* paper size */ |
118 |
+ |
parsepaper(argv[++i]); |
119 |
+ |
break; |
120 |
+ |
case 'm': /* margin */ |
121 |
+ |
d = atof(argv[i+1]); |
122 |
+ |
d *= unit2inch(argv[i+1]); |
123 |
+ |
switch (argv[i][2]) { |
124 |
+ |
case '\0': |
125 |
+ |
hmarg = vmarg = d; |
126 |
+ |
break; |
127 |
+ |
case 'h': |
128 |
+ |
hmarg = d; |
129 |
+ |
break; |
130 |
+ |
case 'v': |
131 |
+ |
vmarg = d; |
132 |
+ |
break; |
133 |
+ |
default: |
134 |
+ |
goto userr; |
135 |
+ |
} |
136 |
+ |
i++; |
137 |
+ |
break; |
138 |
|
case 'e': /* exposure adjustment */ |
139 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
140 |
|
goto userr; |
161 |
|
progname, argv[i+1]); |
162 |
|
exit(1); |
163 |
|
} |
164 |
< |
#ifdef MSDOS |
100 |
< |
setmode(fileno(stdin), O_BINARY); |
101 |
< |
#endif |
164 |
> |
SET_FILE_BINARY(stdin); |
165 |
|
/* get our header */ |
166 |
|
getheader(stdin, headline, NULL); |
167 |
|
if (wrongformat || fgetresolu(&xmax, &ymax, stdin) < 0) |
168 |
|
quiterr("bad picture format"); |
169 |
+ |
/* gamma compression */ |
170 |
+ |
if (devgam <= 0.05) |
171 |
+ |
devgam = docolor ? DEFCGAM : DEFGGAM; |
172 |
+ |
if (putprim == Cputprim) |
173 |
+ |
setcolrgam(CODE6GAM); |
174 |
+ |
else if (devgam != 1.) |
175 |
+ |
setcolrgam(devgam); |
176 |
|
/* write header */ |
177 |
< |
PSheader(i <= argc-1 ? argv[i] : "<stdin>"); |
177 |
> |
PSheader(argc, argv); |
178 |
|
/* convert file */ |
179 |
|
ra2ps(); |
180 |
|
/* write trailer */ |
181 |
|
PStrailer(); |
182 |
|
exit(0); |
183 |
|
userr: |
184 |
< |
fprintf(stderr, "Usage: %s [-c][-e +/-stops] [input [output]]\n", |
184 |
> |
fprintf(stderr, |
185 |
> |
"Usage: %s [-b|c][-A|B|C][-e +/-stops][-p paper][-m[h|v] margin][-d dpi][-g gamma] [input [output]]\n", |
186 |
|
progname); |
187 |
|
exit(1); |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
+ |
double |
192 |
+ |
unit2inch(s) /* determine unit */ |
193 |
+ |
register char *s; |
194 |
+ |
{ |
195 |
+ |
static struct unit {char n; float f;} u[] = { |
196 |
+ |
{'i', 1.}, |
197 |
+ |
{'m', 1./25.4}, |
198 |
+ |
{'c', 1./2.54}, |
199 |
+ |
{'\0',0} }; |
200 |
+ |
register struct unit *up; |
201 |
+ |
|
202 |
+ |
while (*s && !isalpha(*s)) |
203 |
+ |
s++; |
204 |
+ |
for (up = u; up->n; up++) |
205 |
+ |
if (up->n == *s) |
206 |
+ |
return(up->f); |
207 |
+ |
return(1.); |
208 |
+ |
} |
209 |
+ |
|
210 |
+ |
|
211 |
+ |
int |
212 |
+ |
matchid(name, id) /* see if name matches id (case insensitive) */ |
213 |
+ |
char *name; |
214 |
+ |
register char *id; |
215 |
+ |
{ |
216 |
+ |
register char *s = name; |
217 |
+ |
|
218 |
+ |
while (*s) { |
219 |
+ |
if (isalpha(*s)) { |
220 |
+ |
if (!isalpha(*id) || UPPER(*s) != UPPER(*id)) |
221 |
+ |
return(0); |
222 |
+ |
} else if (*s != *id) |
223 |
+ |
return(0); |
224 |
+ |
s++; id++; |
225 |
+ |
} |
226 |
+ |
return(!*id || s-name >= 3); /* substrings >= 3 chars OK */ |
227 |
+ |
} |
228 |
+ |
|
229 |
+ |
|
230 |
+ |
parsepaper(ps) /* determine paper size from name */ |
231 |
+ |
char *ps; |
232 |
+ |
{ |
233 |
+ |
static struct psize {char n[12]; float w,h;} p[] = { |
234 |
+ |
{"envelope", 4.12, 9.5}, |
235 |
+ |
{"executive", 7.25, 10.5}, |
236 |
+ |
{"letter", 8.5, 11.}, |
237 |
+ |
{"lettersmall", 7.68, 10.16}, |
238 |
+ |
{"legal", 8.5, 14.}, |
239 |
+ |
{"monarch", 3.87, 7.5}, |
240 |
+ |
{"statement", 5.5, 8.5}, |
241 |
+ |
{"tabloid", 11., 17.}, |
242 |
+ |
{"A3", 11.69, 16.54}, |
243 |
+ |
{"A4", 8.27, 11.69}, |
244 |
+ |
{"A4small", 7.47, 10.85}, |
245 |
+ |
{"A5", 6.00, 8.27}, |
246 |
+ |
{"A6", 4.13, 6.00}, |
247 |
+ |
{"B4", 10.12, 14.33}, |
248 |
+ |
{"B5", 7.17, 10.12}, |
249 |
+ |
{"C5", 6.38, 9.01}, |
250 |
+ |
{"C6", 4.49, 6.38}, |
251 |
+ |
{"DL", 4.33, 8.66}, |
252 |
+ |
{"hagaki", 3.94, 5.83}, |
253 |
+ |
{"",0.0,0.0} }; |
254 |
+ |
register struct psize *pp; |
255 |
+ |
register char *s = ps; |
256 |
+ |
double d; |
257 |
+ |
|
258 |
+ |
if (isdigit(*s)) { /* check for WWxHH specification */ |
259 |
+ |
width = atof(s); |
260 |
+ |
while (*s && !isalpha(*s)) |
261 |
+ |
s++; |
262 |
+ |
d = unit2inch(s); |
263 |
+ |
height = atof(++s); |
264 |
+ |
width *= d; |
265 |
+ |
height *= d; |
266 |
+ |
if ((width >= 1.) & (height >= 1.)) |
267 |
+ |
return; |
268 |
+ |
} else /* check for match to standard size */ |
269 |
+ |
for (pp = p; pp->n[0]; pp++) |
270 |
+ |
if (matchid(s, pp->n)) { |
271 |
+ |
width = pp->w; |
272 |
+ |
height = pp->h; |
273 |
+ |
return; |
274 |
+ |
} |
275 |
+ |
fprintf(stderr, "%s: unknown paper size \"%s\" -- known sizes:\n", |
276 |
+ |
progname, ps); |
277 |
+ |
fprintf(stderr, "_Name________Width_Height_(inches)\n"); |
278 |
+ |
for (pp = p; pp->n[0]; pp++) |
279 |
+ |
fprintf(stderr, "%-11s %5.2f %5.2f\n", pp->n, pp->w, pp->h); |
280 |
+ |
fprintf(stderr, "Or use WWxHH size specification\n"); |
281 |
+ |
exit(1); |
282 |
+ |
} |
283 |
+ |
|
284 |
+ |
|
285 |
|
quiterr(err) /* print message and exit */ |
286 |
|
char *err; |
287 |
|
{ |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
< |
PSheader(name) /* print PostScript header */ |
297 |
< |
char *name; |
296 |
> |
PSheader(ac, av) /* print PostScript header */ |
297 |
> |
int ac; |
298 |
> |
char **av; |
299 |
|
{ |
300 |
< |
int landscape = 0; |
300 |
> |
char *rstr; |
301 |
> |
int landscape, rotate, n; |
302 |
|
double pwidth, pheight; |
303 |
|
double iwidth, iheight; |
304 |
|
/* EPS comments */ |
305 |
|
puts("%!PS-Adobe-2.0 EPSF-2.0"); |
306 |
< |
printf("%%%%Title: %s\n", name); |
307 |
< |
printf("%%%%Creator: %s = %s\n", progname, SCCSid); |
306 |
> |
printf("%%%%Title: "); printargs(ac, av, stdout); |
307 |
> |
printf("%%%%Creator: %s\n", progname); |
308 |
|
printf("%%%%Pages: %d\n", ncopies); |
309 |
< |
if (landscape = xmax > pixaspect*ymax) |
309 |
> |
if ( (landscape = xmax > pixaspect*ymax) ) |
310 |
|
puts("%%Orientation: Landscape"); |
311 |
|
else |
312 |
|
puts("%%Orientation: Portrait"); |
313 |
< |
if (PWIDTH > PHEIGHT ^ landscape) { |
313 |
> |
if ( (rotate = (PWIDTH > PHEIGHT) ^ landscape) ) { |
314 |
|
pwidth = PHEIGHT; |
315 |
|
pheight = PWIDTH; |
316 |
|
} else { |
317 |
|
pwidth = PWIDTH; |
318 |
|
pheight = PHEIGHT; |
319 |
|
} |
320 |
< |
if (pheight/pwidth > pixaspect*ymax/xmax) { |
321 |
< |
iwidth = pwidth; |
322 |
< |
iheight = pwidth*pixaspect*ymax/xmax; |
323 |
< |
} else { |
324 |
< |
iheight = pheight; |
325 |
< |
iwidth = pheight*xmax/(pixaspect*ymax); |
326 |
< |
} |
327 |
< |
if (pwidth == PHEIGHT) |
320 |
> |
if (dpi > 100 && (pixaspect >= 0.99) & (pixaspect <= 1.01)) |
321 |
> |
if (pheight/pwidth > ymax/xmax) { |
322 |
> |
n = pwidth*dpi/xmax; /* floor */ |
323 |
> |
iwidth = n > 0 ? (double)(n*xmax)/dpi : pwidth; |
324 |
> |
iheight = iwidth*ymax/xmax; |
325 |
> |
} else { |
326 |
> |
n = pheight*dpi/ymax; /* floor */ |
327 |
> |
iheight = n > 0 ? (double)(n*ymax)/dpi : pheight; |
328 |
> |
iwidth = iheight*xmax/ymax; |
329 |
> |
} |
330 |
> |
else |
331 |
> |
if (pheight/pwidth > pixaspect*ymax/xmax) { |
332 |
> |
iwidth = pwidth; |
333 |
> |
iheight = iwidth*pixaspect*ymax/xmax; |
334 |
> |
} else { |
335 |
> |
iheight = pheight; |
336 |
> |
iwidth = iheight*xmax/(pixaspect*ymax); |
337 |
> |
} |
338 |
> |
if (rotate) |
339 |
|
printf("%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", |
340 |
|
HMARGIN+(pheight-iheight)*.5, |
341 |
|
VMARGIN+(pwidth-iwidth)*.5, |
348 |
|
HMARGIN+(pwidth-iwidth)*.5+iwidth, |
349 |
|
VMARGIN+(pheight-iheight)*.5+iheight); |
350 |
|
puts("%%EndComments"); |
351 |
< |
puts("save"); |
352 |
< |
puts("64 dict begin"); |
351 |
> |
puts("gsave save"); |
352 |
> |
puts("17 dict begin"); |
353 |
|
/* define image reader */ |
354 |
|
if (docolor) { |
355 |
|
printf("/redline %d string def\n", xmax); |
356 |
|
printf("/grnline %d string def\n", xmax); |
357 |
|
printf("/bluline %d string def\n", xmax); |
358 |
< |
printf("/rgbline %d string def\n", 3*xmax); |
359 |
< |
PSprocdef("read6bitRLE", "interleave"); |
360 |
< |
} else { |
361 |
< |
printf("/greyline %d string def\n", xmax); |
362 |
< |
PSprocdef("read6bitRLE", NULL); |
185 |
< |
} |
358 |
> |
} else |
359 |
> |
printf("/gryline %d string def\n", xmax); |
360 |
> |
/* use compressed encoding? */ |
361 |
> |
if (putprim == Cputprim) |
362 |
> |
PSprocdef("read6bitRLE"); |
363 |
|
/* set up transformation matrix */ |
364 |
|
printf("%f %f translate\n", HMARGIN, VMARGIN); |
365 |
< |
if (pwidth == PHEIGHT) { |
366 |
< |
printf("0 %f translate\n", PHEIGHT); |
367 |
< |
puts("-90 rotate"); |
365 |
> |
if (rotate) { |
366 |
> |
printf("%f 0 translate\n", PWIDTH); |
367 |
> |
puts("90 rotate"); |
368 |
|
} |
369 |
|
printf("%f %f translate\n", (pwidth-iwidth)*.5, (pheight-iheight)*.5); |
370 |
|
printf("%f %f scale\n", iwidth, iheight); |
371 |
< |
puts("%%%%EndProlog"); |
371 |
> |
puts("%%EndProlog"); |
372 |
|
/* start image procedure */ |
373 |
< |
printf("%d %d 8 [%d 0 0 %d 0 %d] ", xmax, ymax, xmax, -ymax, ymax); |
374 |
< |
if (docolor) { |
375 |
< |
puts("{redline read6bitRLE grnline read6bitRLE"); |
376 |
< |
puts("\tbluline read6bitRLE rgbline interleave} false 3 colorimage"); |
377 |
< |
} else |
378 |
< |
puts("{greyline read6bitRLE} image"); |
373 |
> |
printf("%d %d 8 [%d 0 0 %d 0 %d]\n", xmax, ymax, xmax, -ymax, ymax); |
374 |
> |
if (putprim == Cputprim) { |
375 |
> |
if (docolor) { |
376 |
> |
puts("{redline read6bitRLE}"); |
377 |
> |
puts("{grnline read6bitRLE}"); |
378 |
> |
puts("{bluline read6bitRLE}"); |
379 |
> |
puts("true 3 colorimage"); |
380 |
> |
} else |
381 |
> |
puts("{gryline read6bitRLE} image"); |
382 |
> |
} else { |
383 |
> |
rstr = putprim==Aputprim ? "readhexstring" : "readstring"; |
384 |
> |
if (docolor) { |
385 |
> |
printf("{currentfile redline %s pop}\n", rstr); |
386 |
> |
printf("{currentfile grnline %s pop}\n", rstr); |
387 |
> |
printf("{currentfile bluline %s pop}\n", rstr); |
388 |
> |
puts("true 3 colorimage"); |
389 |
> |
} else |
390 |
> |
printf("{currentfile gryline %s pop} image\n", rstr); |
391 |
> |
} |
392 |
|
} |
393 |
|
|
394 |
|
|
399 |
|
printf("/#copies %d def\n", ncopies); |
400 |
|
puts("showpage"); |
401 |
|
puts("end"); |
402 |
< |
puts("restore"); |
402 |
> |
puts("restore grestore"); |
403 |
|
puts("%%EOF"); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
< |
PSprocdef(nam, inam) /* define PS procedure to read image */ |
408 |
< |
char *nam, *inam; |
407 |
> |
PSprocdef(nam) /* define PS procedure to read image */ |
408 |
> |
char *nam; |
409 |
|
{ |
410 |
|
short itab[128]; |
411 |
|
register int i; |
413 |
|
for (i = 0; i < 128; i++) /* clear */ |
414 |
|
itab[i] = -1; |
415 |
|
for (i = 1; i < 63; i++) /* assign greys */ |
416 |
< |
itab[code[i]] = i<<2 | 2; |
416 |
> |
itab[code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM/devgam); |
417 |
|
itab[code[0]] = 0; /* black is black */ |
418 |
|
itab[code[63]] = 255; /* and white is white */ |
419 |
|
printf("/codetab ["); |
441 |
|
printf("\t\t} for\n"); |
442 |
|
printf("\t} stopped {pop pop 0 string} {scanline} ifelse\n"); |
443 |
|
printf("} bind def\n"); |
254 |
– |
if (inam == NULL) |
255 |
– |
return; |
256 |
– |
/* define interleaving procedure */ |
257 |
– |
printf("/%s {\t%% redscn grnscn bluscn rgbscn\n", inam); |
258 |
– |
printf("\t/rgbscan exch def /bscan exch def\n"); |
259 |
– |
printf("\t/gscan exch def /rscan exch def\n"); |
260 |
– |
printf("\trscan length %d eq gscan length %d eq and ", xmax, xmax); |
261 |
– |
printf("bscan length %d eq and \n", xmax); |
262 |
– |
printf("\t{ 0 1 %d { /ndx exch def\n", xmax-1); |
263 |
– |
printf("\t\trgbscan ndx 3 mul rscan ndx get put\n"); |
264 |
– |
printf("\t\trgbscan ndx 3 mul 1 add gscan ndx get put\n"); |
265 |
– |
printf("\t\trgbscan ndx 3 mul 2 add bscan ndx get put\n"); |
266 |
– |
printf("\t\t} for rgbscan }\n"); |
267 |
– |
printf("\t{0 string} ifelse\n"); |
268 |
– |
printf("} bind def\n"); |
444 |
|
} |
445 |
|
|
446 |
|
|
456 |
|
for (y = ymax-1; y >= 0; y--) { |
457 |
|
if (freadcolrs(scanin, xmax, stdin) < 0) |
458 |
|
quiterr("error reading Radiance picture"); |
459 |
< |
normcolrs(scanin, xmax, bradj); /* normalize */ |
459 |
> |
if (putprim == Cputprim || devgam != 1.) { |
460 |
> |
if (bradj) /* adjust exposure */ |
461 |
> |
shiftcolrs(scanin, xmax, bradj); |
462 |
> |
colrs_gambs(scanin, xmax); /* gamma compression */ |
463 |
> |
} else |
464 |
> |
normcolrs(scanin, xmax, bradj); |
465 |
|
if (docolor) { |
466 |
< |
putprim(scanin, RED); |
467 |
< |
putprim(scanin, GRN); |
468 |
< |
putprim(scanin, BLU); |
466 |
> |
(*putprim)(scanin, RED); |
467 |
> |
(*putprim)(scanin, GRN); |
468 |
> |
(*putprim)(scanin, BLU); |
469 |
|
} else |
470 |
< |
putprim(scanin, GRY); |
470 |
> |
(*putprim)(scanin, GRY); |
471 |
|
if (ferror(stdout)) |
472 |
|
quiterr("error writing PostScript file"); |
473 |
|
} |
474 |
|
putchar('\n'); |
475 |
|
/* free scanline */ |
476 |
< |
free((char *)scanin); |
476 |
> |
free((void *)scanin); |
477 |
|
} |
478 |
|
|
479 |
|
|
480 |
< |
putprim(scn, pri) /* put out one primary from scanline */ |
480 |
> |
int |
481 |
> |
Aputprim(scn, pri) /* put out hex ASCII primary from scanline */ |
482 |
> |
COLR *scn; |
483 |
> |
int pri; |
484 |
> |
{ |
485 |
> |
static char hexdigit[] = "0123456789ABCDEF"; |
486 |
> |
static int col = 0; |
487 |
> |
register int x, c; |
488 |
> |
|
489 |
> |
for (x = 0; x < xmax; x++) { |
490 |
> |
if (pri == GRY) |
491 |
> |
c = normbright(scn[x]); |
492 |
> |
else |
493 |
> |
c = scn[x][pri]; |
494 |
> |
if (c > 255) c = 255; |
495 |
> |
putchar(hexdigit[c>>4]); |
496 |
> |
putchar(hexdigit[c&0xf]); |
497 |
> |
if ((col += 2) >= 72) { |
498 |
> |
putchar('\n'); |
499 |
> |
col = 0; |
500 |
> |
} |
501 |
> |
} |
502 |
> |
} |
503 |
> |
|
504 |
> |
|
505 |
> |
int |
506 |
> |
Bputprim(scn, pri) /* put out binary primary from scanline */ |
507 |
> |
COLR *scn; |
508 |
> |
int pri; |
509 |
> |
{ |
510 |
> |
register int x, c; |
511 |
> |
|
512 |
> |
for (x = 0; x < xmax; x++) { |
513 |
> |
if (pri == GRY) |
514 |
> |
c = normbright(scn[x]); |
515 |
> |
else |
516 |
> |
c = scn[x][pri]; |
517 |
> |
if (c > 255) c = 255; |
518 |
> |
putchar(c); |
519 |
> |
} |
520 |
> |
} |
521 |
> |
|
522 |
> |
|
523 |
> |
int |
524 |
> |
Cputprim(scn, pri) /* put out compressed primary from scanline */ |
525 |
|
COLR *scn; |
526 |
|
int pri; |
527 |
|
{ |