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 |
|
* pvalue.c - program to print pixel values. |
6 |
|
* |
11 |
|
|
12 |
|
#include "color.h" |
13 |
|
|
14 |
+ |
#include <time.h> |
15 |
+ |
|
16 |
|
#include "resolu.h" |
17 |
|
|
18 |
+ |
typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ |
19 |
+ |
|
20 |
|
#define min(a,b) ((a)<(b)?(a):(b)) |
21 |
|
|
22 |
|
/* what to put out (also RED, GRN, BLU) */ |
44 |
|
|
45 |
|
long skipbytes = 0; /* skip bytes in input? */ |
46 |
|
|
47 |
+ |
int swapbytes = 0; /* swap bytes in 16-bit words? */ |
48 |
+ |
|
49 |
+ |
int interleave = 1; /* file is interleaved? */ |
50 |
+ |
|
51 |
|
int resolution = 1; /* put/get resolution string? */ |
52 |
|
|
53 |
|
int original = 0; /* convert to original values? */ |
68 |
|
|
69 |
|
int (*getval)(), (*putval)(); |
70 |
|
|
71 |
+ |
double |
72 |
+ |
rgb_bright(clr) |
73 |
+ |
COLOR clr; |
74 |
+ |
{ |
75 |
+ |
return(bright(clr)); |
76 |
+ |
} |
77 |
|
|
78 |
+ |
double |
79 |
+ |
xyz_bright(clr) |
80 |
+ |
COLOR clr; |
81 |
+ |
{ |
82 |
+ |
return(clr[CIEY]); |
83 |
+ |
} |
84 |
+ |
|
85 |
+ |
double (*mybright)() = &rgb_bright; |
86 |
+ |
|
87 |
+ |
|
88 |
|
main(argc, argv) |
89 |
|
int argc; |
90 |
|
char **argv; |
140 |
|
case 'r': /* reverse conversion */ |
141 |
|
reverse = argv[i][0] == '-'; |
142 |
|
break; |
143 |
+ |
case 'n': /* non-interleaved RGB */ |
144 |
+ |
interleave = argv[i][0] == '+'; |
145 |
+ |
break; |
146 |
|
case 'b': /* brightness values */ |
147 |
|
putprim = argv[i][0] == '-' ? BRIGHT : ALL; |
148 |
|
break; |
171 |
|
format = 'b'; |
172 |
|
fmtid = "byte"; |
173 |
|
break; |
174 |
+ |
case 'W': /* 16-bit swapped */ |
175 |
+ |
swapbytes = 1; |
176 |
+ |
case 'w': /* 16-bit */ |
177 |
+ |
dataonly = 1; |
178 |
+ |
format = 'w'; |
179 |
+ |
fmtid = "16-bit"; |
180 |
+ |
break; |
181 |
|
case 'f': /* float */ |
182 |
|
dataonly = 1; |
183 |
|
format = 'f'; |
196 |
|
case 'X': /* x resolution */ |
197 |
|
resolution = 0; |
198 |
|
if (argv[i][0] == '-') |
199 |
< |
picres.or |= XDECR; |
199 |
> |
picres.rt |= XDECR; |
200 |
|
picres.xr = atoi(argv[++i]); |
201 |
|
break; |
202 |
|
case 'y': /* y resolution */ |
203 |
|
case 'Y': /* y resolution */ |
204 |
|
resolution = 0; |
205 |
|
if (argv[i][0] == '-') |
206 |
< |
picres.or |= YDECR; |
206 |
> |
picres.rt |= YDECR; |
207 |
|
if (picres.xr == 0) |
208 |
< |
picres.or |= YMAJOR; |
208 |
> |
picres.rt |= YMAJOR; |
209 |
|
picres.yr = atoi(argv[++i]); |
210 |
|
break; |
211 |
|
default: |
223 |
|
fmtid = "8-bit_grey"; |
224 |
|
else |
225 |
|
fmtid = "24-bit_rgb"; |
226 |
+ |
if (dataonly && format == 'w') |
227 |
+ |
if (brightonly) |
228 |
+ |
fmtid = "16-bit_grey"; |
229 |
+ |
else |
230 |
+ |
fmtid = "48-bit_rgb"; |
231 |
|
/* assign reverse ordering */ |
232 |
|
rord[ord[0]] = 0; |
233 |
|
rord[ord[1]] = 1; |
241 |
|
progname, argv[i]); |
242 |
|
quit(1); |
243 |
|
} |
208 |
– |
if (skipbytes && fseek(fin, skipbytes, 0)) |
209 |
– |
goto seekerr; |
244 |
|
if (reverse && !brightonly && i == argc-3) { |
245 |
|
if ((fin2 = fopen(argv[i+1], "r")) == NULL) { |
246 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
252 |
|
progname, argv[i+2]); |
253 |
|
quit(1); |
254 |
|
} |
255 |
< |
if (skipbytes && (fseek(fin2, skipbytes, 0) || |
222 |
< |
fseek(fin3, skipbytes, 0))) |
223 |
< |
goto seekerr; |
255 |
> |
interleave = -1; |
256 |
|
} else if (i != argc-1) |
257 |
|
fin = NULL; |
258 |
+ |
if (reverse && !brightonly && !interleave) { |
259 |
+ |
fin2 = fopen(argv[i], "r"); |
260 |
+ |
fin3 = fopen(argv[i], "r"); |
261 |
+ |
} |
262 |
+ |
if (skipbytes && (fseek(fin, skipbytes, 0) || (fin2 != NULL && |
263 |
+ |
(fseek(fin2, skipbytes, 0) || |
264 |
+ |
fseek(fin3, skipbytes, 0))))) { |
265 |
+ |
fprintf(stderr, "%s: cannot skip %ld bytes on input\n", |
266 |
+ |
progname, skipbytes); |
267 |
+ |
quit(1); |
268 |
+ |
} |
269 |
|
} |
270 |
|
if (fin == NULL) { |
271 |
|
fprintf(stderr, "%s: bad # file arguments\n", progname); |
272 |
|
quit(1); |
273 |
|
} |
274 |
|
|
232 |
– |
set_io(); |
233 |
– |
|
275 |
|
if (reverse) { |
276 |
|
#ifdef MSDOS |
277 |
|
setmode(fileno(stdout), O_BINARY); |
300 |
|
if (resolution && fin2 != NULL) { |
301 |
|
RESOLU pres2; |
302 |
|
if (!fgetsresolu(&pres2, fin2) || |
303 |
< |
pres2.or != picres.or || |
303 |
> |
pres2.rt != picres.rt || |
304 |
|
pres2.xr != picres.xr || |
305 |
|
pres2.yr != picres.yr || |
306 |
|
!fgetsresolu(&pres2, fin3) || |
307 |
< |
pres2.or != picres.or || |
307 |
> |
pres2.rt != picres.rt || |
308 |
|
pres2.xr != picres.xr || |
309 |
|
pres2.yr != picres.yr) { |
310 |
|
fprintf(stderr, "%s: resolution mismatch\n", |
329 |
|
/* get header */ |
330 |
|
getheader(fin, checkhead, NULL); |
331 |
|
if (wrongformat) { |
332 |
< |
fprintf(stderr, "%s: input not a Radiance picture\n", |
332 |
> |
fprintf(stderr, |
333 |
> |
"%s: input not a Radiance RGBE picture\n", |
334 |
|
progname); |
335 |
|
quit(1); |
336 |
|
} |
351 |
|
} |
352 |
|
|
353 |
|
quit(0); |
312 |
– |
seekerr: |
313 |
– |
fprintf(stderr, "%s: cannot skip %ld bytes on input\n", |
314 |
– |
progname, skipbytes); |
315 |
– |
quit(1); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
+ |
int |
358 |
|
checkhead(line) /* deal with line from header */ |
359 |
|
char *line; |
360 |
|
{ |
362 |
|
double d; |
363 |
|
COLOR ctmp; |
364 |
|
|
365 |
< |
if (formatval(fmt, line)) |
366 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
367 |
< |
else if (original && isexpos(line)) { |
365 |
> |
if (formatval(fmt, line)) { |
366 |
> |
if (!strcmp(fmt, CIEFMT)) { |
367 |
> |
mybright = &xyz_bright; |
368 |
> |
if (original) { |
369 |
> |
scalecolor(exposure, 1./WHTEFFICACY); |
370 |
> |
doexposure++; |
371 |
> |
} |
372 |
> |
} else if (!strcmp(fmt, COLRFMT)) |
373 |
> |
mybright = &rgb_bright; |
374 |
> |
else |
375 |
> |
wrongformat++; |
376 |
> |
} else if (original && isexpos(line)) { |
377 |
|
d = 1.0/exposval(line); |
378 |
|
scalecolor(exposure, d); |
379 |
|
doexposure++; |
385 |
|
doexposure++; |
386 |
|
} else if (header) |
387 |
|
fputs(line, stdout); |
388 |
+ |
return(0); |
389 |
|
} |
390 |
|
|
391 |
|
|
395 |
|
int dogamma; |
396 |
|
COLOR lastc; |
397 |
|
FLOAT hv[2]; |
398 |
+ |
int startprim, endprim; |
399 |
+ |
long startpos; |
400 |
|
int y; |
401 |
|
register int x; |
402 |
|
|
406 |
|
quit(1); |
407 |
|
} |
408 |
|
dogamma = gamcor < .95 || gamcor > 1.05; |
409 |
< |
setcolor(lastc, 0.0, 0.0, 0.0); |
410 |
< |
for (y = 0; y < numscans(&picres); y++) { |
411 |
< |
if (freadscan(scanln, scanlen(&picres), fin) < 0) { |
412 |
< |
fprintf(stderr, "%s: read error\n", progname); |
409 |
> |
if (putprim == ALL && !interleave) { |
410 |
> |
startprim = RED; endprim = BLU; |
411 |
> |
startpos = ftell(fin); |
412 |
> |
} else { |
413 |
> |
startprim = putprim; endprim = putprim; |
414 |
> |
} |
415 |
> |
for (putprim = startprim; putprim <= endprim; putprim++) { |
416 |
> |
if (putprim != startprim && fseek(fin, startpos, 0)) { |
417 |
> |
fprintf(stderr, "%s: seek error on input file\n", |
418 |
> |
progname); |
419 |
|
quit(1); |
420 |
|
} |
421 |
< |
for (x = 0; x < scanlen(&picres); x++) { |
422 |
< |
if (uniq) |
423 |
< |
if ( colval(scanln[x],RED) == |
424 |
< |
colval(lastc,RED) && |
425 |
< |
colval(scanln[x],GRN) == |
369 |
< |
colval(lastc,GRN) && |
370 |
< |
colval(scanln[x],BLU) == |
371 |
< |
colval(lastc,BLU) ) |
372 |
< |
continue; |
373 |
< |
else |
374 |
< |
copycolor(lastc, scanln[x]); |
375 |
< |
if (doexposure) |
376 |
< |
multcolor(scanln[x], exposure); |
377 |
< |
if (dogamma) |
378 |
< |
setcolor(scanln[x], |
379 |
< |
pow(colval(scanln[x],RED), 1.0/gamcor), |
380 |
< |
pow(colval(scanln[x],GRN), 1.0/gamcor), |
381 |
< |
pow(colval(scanln[x],BLU), 1.0/gamcor)); |
382 |
< |
if (!dataonly) { |
383 |
< |
pix2loc(hv, &picres, x, y); |
384 |
< |
printf("%7d %7d ", (int)(hv[0]*picres.xr), |
385 |
< |
(int)(hv[1]*picres.yr)); |
386 |
< |
} |
387 |
< |
if ((*putval)(scanln[x]) < 0) { |
388 |
< |
fprintf(stderr, "%s: write error\n", progname); |
421 |
> |
set_io(); |
422 |
> |
setcolor(lastc, 0.0, 0.0, 0.0); |
423 |
> |
for (y = 0; y < numscans(&picres); y++) { |
424 |
> |
if (freadscan(scanln, scanlen(&picres), fin) < 0) { |
425 |
> |
fprintf(stderr, "%s: read error\n", progname); |
426 |
|
quit(1); |
427 |
|
} |
428 |
+ |
for (x = 0; x < scanlen(&picres); x++) { |
429 |
+ |
if (uniq) |
430 |
+ |
if ( colval(scanln[x],RED) == |
431 |
+ |
colval(lastc,RED) && |
432 |
+ |
colval(scanln[x],GRN) == |
433 |
+ |
colval(lastc,GRN) && |
434 |
+ |
colval(scanln[x],BLU) == |
435 |
+ |
colval(lastc,BLU) ) |
436 |
+ |
continue; |
437 |
+ |
else |
438 |
+ |
copycolor(lastc, scanln[x]); |
439 |
+ |
if (doexposure) |
440 |
+ |
multcolor(scanln[x], exposure); |
441 |
+ |
if (dogamma) |
442 |
+ |
setcolor(scanln[x], |
443 |
+ |
pow(colval(scanln[x],RED), 1.0/gamcor), |
444 |
+ |
pow(colval(scanln[x],GRN), 1.0/gamcor), |
445 |
+ |
pow(colval(scanln[x],BLU), 1.0/gamcor)); |
446 |
+ |
if (!dataonly) { |
447 |
+ |
pix2loc(hv, &picres, x, y); |
448 |
+ |
printf("%7d %7d ", |
449 |
+ |
(int)(hv[0]*picres.xr), |
450 |
+ |
(int)(hv[1]*picres.yr)); |
451 |
+ |
} |
452 |
+ |
if ((*putval)(scanln[x]) < 0) { |
453 |
+ |
fprintf(stderr, "%s: write error\n", |
454 |
+ |
progname); |
455 |
+ |
quit(1); |
456 |
+ |
} |
457 |
+ |
} |
458 |
|
} |
459 |
|
} |
460 |
< |
free((char *)scanln); |
460 |
> |
free((void *)scanln); |
461 |
|
} |
462 |
|
|
463 |
|
|
474 |
|
quit(1); |
475 |
|
} |
476 |
|
dogamma = gamcor < .95 || gamcor > 1.05; |
477 |
+ |
set_io(); |
478 |
|
for (y = 0; y < numscans(&picres); y++) { |
479 |
|
for (x = 0; x < scanlen(&picres); x++) { |
480 |
|
if (!dataonly) { |
501 |
|
quit(1); |
502 |
|
} |
503 |
|
} |
504 |
< |
free((char *)scanln); |
504 |
> |
free((void *)scanln); |
505 |
|
} |
506 |
|
|
507 |
|
|
508 |
+ |
void |
509 |
|
quit(code) |
510 |
|
int code; |
511 |
|
{ |
513 |
|
} |
514 |
|
|
515 |
|
|
516 |
+ |
swap16(wp, n) /* swap n 16-bit words */ |
517 |
+ |
register uint16 *wp; |
518 |
+ |
int n; |
519 |
+ |
{ |
520 |
+ |
while (n-- > 0) { |
521 |
+ |
*wp = *wp << 8 | ((*wp >> 8) & 0xff); |
522 |
+ |
wp++; |
523 |
+ |
} |
524 |
+ |
} |
525 |
+ |
|
526 |
|
getcascii(col) /* get an ascii color value from stream(s) */ |
527 |
|
COLOR col; |
528 |
|
{ |
620 |
|
} |
621 |
|
|
622 |
|
|
623 |
+ |
getcword(col) /* get a 16-bit color value from stream(s) */ |
624 |
+ |
COLOR col; |
625 |
+ |
{ |
626 |
+ |
uint16 vw[3]; |
627 |
+ |
|
628 |
+ |
if (fin2 == NULL) { |
629 |
+ |
if (fread((char *)vw, sizeof(uint16), 3, fin) != 3) |
630 |
+ |
return(-1); |
631 |
+ |
} else { |
632 |
+ |
if (fread((char *)vw, sizeof(uint16), 1, fin) != 1 || |
633 |
+ |
fread((char *)(vw+1), sizeof(uint16), 1, fin2) != 1 || |
634 |
+ |
fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1) |
635 |
+ |
return(-1); |
636 |
+ |
} |
637 |
+ |
if (swapbytes) |
638 |
+ |
swap16(vw, 3); |
639 |
+ |
setcolor(col, (vw[rord[RED]]+.5)/65536., |
640 |
+ |
(vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.); |
641 |
+ |
return(0); |
642 |
+ |
} |
643 |
+ |
|
644 |
+ |
|
645 |
|
getbascii(col) /* get an ascii brightness value from fin */ |
646 |
|
COLOR col; |
647 |
|
{ |
706 |
|
} |
707 |
|
|
708 |
|
|
709 |
+ |
getbword(col) /* get a 16-bit brightness value from fin */ |
710 |
+ |
COLOR col; |
711 |
+ |
{ |
712 |
+ |
uint16 vw; |
713 |
+ |
double d; |
714 |
+ |
|
715 |
+ |
if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1) |
716 |
+ |
return(-1); |
717 |
+ |
if (swapbytes) |
718 |
+ |
swap16(&vw, 1); |
719 |
+ |
d = (vw+.5)/65536.; |
720 |
+ |
setcolor(col, d, d, d); |
721 |
+ |
return(0); |
722 |
+ |
} |
723 |
+ |
|
724 |
+ |
|
725 |
|
putcascii(col) /* put an ascii color to stdout */ |
726 |
|
COLOR col; |
727 |
|
{ |
777 |
|
putcbyte(col) /* put a byte color to stdout */ |
778 |
|
COLOR col; |
779 |
|
{ |
780 |
< |
register int i; |
780 |
> |
long i; |
781 |
|
BYTE vb[3]; |
782 |
|
|
783 |
|
i = colval(col,ord[0])*256.; |
792 |
|
} |
793 |
|
|
794 |
|
|
795 |
+ |
putcword(col) /* put a 16-bit color to stdout */ |
796 |
+ |
COLOR col; |
797 |
+ |
{ |
798 |
+ |
long i; |
799 |
+ |
uint16 vw[3]; |
800 |
+ |
|
801 |
+ |
i = colval(col,ord[0])*65536.; |
802 |
+ |
vw[0] = min(i,65535); |
803 |
+ |
i = colval(col,ord[1])*65536.; |
804 |
+ |
vw[1] = min(i,65535); |
805 |
+ |
i = colval(col,ord[2])*65536.; |
806 |
+ |
vw[2] = min(i,65535); |
807 |
+ |
if (swapbytes) |
808 |
+ |
swap16(vw, 3); |
809 |
+ |
fwrite((char *)vw, sizeof(uint16), 3, stdout); |
810 |
+ |
|
811 |
+ |
return(ferror(stdout) ? -1 : 0); |
812 |
+ |
} |
813 |
+ |
|
814 |
+ |
|
815 |
|
putbascii(col) /* put an ascii brightness to stdout */ |
816 |
|
COLOR col; |
817 |
|
{ |
818 |
< |
fprintf(stdout, "%15.3e\n", bright(col)); |
818 |
> |
fprintf(stdout, "%15.3e\n", (*mybright)(col)); |
819 |
|
|
820 |
|
return(ferror(stdout) ? -1 : 0); |
821 |
|
} |
826 |
|
{ |
827 |
|
float vf; |
828 |
|
|
829 |
< |
vf = bright(col); |
829 |
> |
vf = (*mybright)(col); |
830 |
|
fwrite((char *)&vf, sizeof(float), 1, stdout); |
831 |
|
|
832 |
|
return(ferror(stdout) ? -1 : 0); |
838 |
|
{ |
839 |
|
double vd; |
840 |
|
|
841 |
< |
vd = bright(col); |
841 |
> |
vd = (*mybright)(col); |
842 |
|
fwrite((char *)&vd, sizeof(double), 1, stdout); |
843 |
|
|
844 |
|
return(ferror(stdout) ? -1 : 0); |
848 |
|
putbint(col) /* put an int brightness to stdout */ |
849 |
|
COLOR col; |
850 |
|
{ |
851 |
< |
fprintf(stdout, "%d\n", (int)(bright(col)*256.)); |
851 |
> |
fprintf(stdout, "%d\n", (int)((*mybright)(col)*256.)); |
852 |
|
|
853 |
|
return(ferror(stdout) ? -1 : 0); |
854 |
|
} |
860 |
|
register int i; |
861 |
|
BYTE vb; |
862 |
|
|
863 |
< |
i = bright(col)*256.; |
863 |
> |
i = (*mybright)(col)*256.; |
864 |
|
vb = min(i,255); |
865 |
|
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
866 |
|
|
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
+ |
putbword(col) /* put a 16-bit brightness to stdout */ |
872 |
+ |
COLOR col; |
873 |
+ |
{ |
874 |
+ |
long i; |
875 |
+ |
uint16 vw; |
876 |
+ |
|
877 |
+ |
i = (*mybright)(col)*65536.; |
878 |
+ |
vw = min(i,65535); |
879 |
+ |
if (swapbytes) |
880 |
+ |
swap16(&vw, 1); |
881 |
+ |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
882 |
+ |
|
883 |
+ |
return(ferror(stdout) ? -1 : 0); |
884 |
+ |
} |
885 |
+ |
|
886 |
+ |
|
887 |
|
putpascii(col) /* put an ascii primary to stdout */ |
888 |
|
COLOR col; |
889 |
|
{ |
929 |
|
putpbyte(col) /* put a byte primary to stdout */ |
930 |
|
COLOR col; |
931 |
|
{ |
932 |
< |
register int i; |
932 |
> |
long i; |
933 |
|
BYTE vb; |
934 |
|
|
935 |
|
i = colval(col,putprim)*256.; |
940 |
|
} |
941 |
|
|
942 |
|
|
943 |
+ |
putpword(col) /* put a 16-bit primary to stdout */ |
944 |
+ |
COLOR col; |
945 |
+ |
{ |
946 |
+ |
long i; |
947 |
+ |
uint16 vw; |
948 |
+ |
|
949 |
+ |
i = colval(col,putprim)*65536.; |
950 |
+ |
vw = min(i,65535); |
951 |
+ |
if (swapbytes) |
952 |
+ |
swap16(&vw, 1); |
953 |
+ |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
954 |
+ |
|
955 |
+ |
return(ferror(stdout) ? -1 : 0); |
956 |
+ |
} |
957 |
+ |
|
958 |
+ |
|
959 |
|
set_io() /* set put and get functions */ |
960 |
|
{ |
961 |
|
switch (format) { |
969 |
|
} else { |
970 |
|
getval = getcascii; |
971 |
|
putval = putcascii; |
972 |
+ |
if (reverse && !interleave) { |
973 |
+ |
fprintf(stderr, |
974 |
+ |
"%s: ASCII input files must be interleaved\n", |
975 |
+ |
progname); |
976 |
+ |
quit(1); |
977 |
+ |
} |
978 |
|
} |
979 |
|
return; |
980 |
|
case 'f': /* binary float */ |
987 |
|
} else { |
988 |
|
getval = getcfloat; |
989 |
|
putval = putcfloat; |
990 |
+ |
if (reverse && !interleave) { |
991 |
+ |
if (fin2 == NULL) |
992 |
+ |
goto namerr; |
993 |
+ |
if (fseek(fin2, |
994 |
+ |
(long)sizeof(float)*picres.xr*picres.yr, 1)) |
995 |
+ |
goto seekerr; |
996 |
+ |
if (fseek(fin3, |
997 |
+ |
(long)sizeof(float)*2*picres.xr*picres.yr, 1)) |
998 |
+ |
goto seekerr; |
999 |
+ |
} |
1000 |
|
} |
1001 |
|
return; |
1002 |
|
case 'd': /* binary double */ |
1009 |
|
} else { |
1010 |
|
getval = getcdouble; |
1011 |
|
putval = putcdouble; |
1012 |
+ |
if (reverse && !interleave) { |
1013 |
+ |
if (fin2 == NULL) |
1014 |
+ |
goto namerr; |
1015 |
+ |
if (fseek(fin2, |
1016 |
+ |
(long)sizeof(double)*picres.xr*picres.yr, 1)) |
1017 |
+ |
goto seekerr; |
1018 |
+ |
if (fseek(fin3, |
1019 |
+ |
(long)sizeof(double)*2*picres.xr*picres.yr, 1)) |
1020 |
+ |
goto seekerr; |
1021 |
+ |
} |
1022 |
|
} |
1023 |
|
return; |
1024 |
|
case 'i': /* integer */ |
1031 |
|
} else { |
1032 |
|
getval = getcint; |
1033 |
|
putval = putcint; |
1034 |
+ |
if (reverse && !interleave) { |
1035 |
+ |
fprintf(stderr, |
1036 |
+ |
"%s: integer input files must be interleaved\n", |
1037 |
+ |
progname); |
1038 |
+ |
quit(1); |
1039 |
+ |
} |
1040 |
|
} |
1041 |
|
return; |
1042 |
|
case 'b': /* byte */ |
1049 |
|
} else { |
1050 |
|
getval = getcbyte; |
1051 |
|
putval = putcbyte; |
1052 |
+ |
if (reverse && !interleave) { |
1053 |
+ |
if (fin2 == NULL) |
1054 |
+ |
goto namerr; |
1055 |
+ |
if (fseek(fin2, |
1056 |
+ |
(long)sizeof(BYTE)*picres.xr*picres.yr, 1)) |
1057 |
+ |
goto seekerr; |
1058 |
+ |
if (fseek(fin3, |
1059 |
+ |
(long)sizeof(BYTE)*2*picres.xr*picres.yr, 1)) |
1060 |
+ |
goto seekerr; |
1061 |
+ |
} |
1062 |
|
} |
1063 |
|
return; |
1064 |
+ |
case 'w': /* 16-bit */ |
1065 |
+ |
if (putprim == BRIGHT) { |
1066 |
+ |
getval = getbword; |
1067 |
+ |
putval = putbword; |
1068 |
+ |
} else if (putprim != ALL) { |
1069 |
+ |
getval = getbword; |
1070 |
+ |
putval = putpword; |
1071 |
+ |
} else { |
1072 |
+ |
getval = getcword; |
1073 |
+ |
putval = putcword; |
1074 |
+ |
if (reverse && !interleave) { |
1075 |
+ |
if (fin2 == NULL) |
1076 |
+ |
goto namerr; |
1077 |
+ |
if (fseek(fin2, |
1078 |
+ |
(long)sizeof(uint16)*picres.xr*picres.yr, 1)) |
1079 |
+ |
goto seekerr; |
1080 |
+ |
if (fseek(fin3, |
1081 |
+ |
(long)sizeof(uint16)*2*picres.xr*picres.yr, 1)) |
1082 |
+ |
goto seekerr; |
1083 |
+ |
} |
1084 |
+ |
} |
1085 |
+ |
return; |
1086 |
|
} |
1087 |
+ |
badopt: |
1088 |
+ |
fprintf(stderr, "%s: botched file type\n", progname); |
1089 |
+ |
quit(1); |
1090 |
+ |
namerr: |
1091 |
+ |
fprintf(stderr, "%s: non-interleaved file(s) must be named\n", |
1092 |
+ |
progname); |
1093 |
+ |
quit(1); |
1094 |
+ |
seekerr: |
1095 |
+ |
fprintf(stderr, "%s: cannot seek on interleaved input file\n", |
1096 |
+ |
progname); |
1097 |
+ |
quit(1); |
1098 |
|
} |