7 |
|
* 4/23/86 |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include "platform.h" |
11 |
|
#include "standard.h" |
11 |
– |
|
12 |
|
#include "color.h" |
13 |
– |
|
14 |
– |
#include <time.h> |
15 |
– |
|
13 |
|
#include "resolu.h" |
14 |
+ |
#include "view.h" |
15 |
|
|
18 |
– |
typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ |
19 |
– |
|
16 |
|
#define min(a,b) ((a)<(b)?(a):(b)) |
17 |
|
|
18 |
|
/* what to put out (also RED, GRN, BLU) */ |
19 |
|
#define ALL 3 |
20 |
|
#define BRIGHT 4 |
21 |
|
|
26 |
– |
#define brightonly (putprim==BRIGHT) |
27 |
– |
|
22 |
|
RESOLU picres; /* resolution of picture */ |
29 |
– |
|
23 |
|
int uniq = 0; /* print only unique values? */ |
31 |
– |
|
24 |
|
int doexposure = 0; /* exposure change? (>100 to print) */ |
33 |
– |
|
25 |
|
int dataonly = 0; /* data only format? */ |
35 |
– |
|
26 |
|
int putprim = ALL; /* what to put out */ |
37 |
– |
|
27 |
|
int reverse = 0; /* reverse conversion? */ |
39 |
– |
|
28 |
|
int format = 'a'; /* input/output format */ |
29 |
|
char *fmtid = "ascii"; /* format identifier for header */ |
42 |
– |
|
30 |
|
int header = 1; /* do header? */ |
44 |
– |
|
31 |
|
long skipbytes = 0; /* skip bytes in input? */ |
32 |
< |
|
47 |
< |
int swapbytes = 0; /* swap bytes in 16-bit words? */ |
48 |
< |
|
32 |
> |
int swapbytes = 0; /* swap bytes? */ |
33 |
|
int interleave = 1; /* file is interleaved? */ |
50 |
– |
|
34 |
|
int resolution = 1; /* put/get resolution string? */ |
52 |
– |
|
35 |
|
int original = 0; /* convert to original values? */ |
54 |
– |
|
36 |
|
int wrongformat = 0; /* wrong input format? */ |
56 |
– |
|
37 |
|
double gamcor = 1.0; /* gamma correction */ |
38 |
|
|
39 |
+ |
RGBPRIMP outprims = stdprims; /* output primaries for reverse conversion */ |
40 |
+ |
RGBPRIMS myprims; |
41 |
+ |
|
42 |
|
int ord[3] = {RED, GRN, BLU}; /* RGB ordering */ |
43 |
|
int rord[4]; /* reverse ordering */ |
44 |
|
|
49 |
|
FILE *fin; |
50 |
|
FILE *fin2 = NULL, *fin3 = NULL; /* for other color channels */ |
51 |
|
|
69 |
– |
int (*getval)(), (*putval)(); |
52 |
|
|
53 |
< |
double |
54 |
< |
rgb_bright(clr) |
55 |
< |
COLOR clr; |
53 |
> |
typedef int getfunc_t(COLOR col); |
54 |
> |
typedef int putfunc_t(COLOR col); |
55 |
> |
typedef double brightfunc_t(COLOR col); |
56 |
> |
|
57 |
> |
getfunc_t *getval; |
58 |
> |
putfunc_t *putval; |
59 |
> |
brightfunc_t *mybright; |
60 |
> |
|
61 |
> |
static gethfunc checkhead; |
62 |
> |
static brightfunc_t rgb_bright, xyz_bright; |
63 |
> |
static getfunc_t getbascii, getbint, getbdouble, getbfloat, getbbyte, getbword; |
64 |
> |
static getfunc_t getcascii, getcint, getcdouble, getcfloat, getcbyte, getcword; |
65 |
> |
static putfunc_t putbascii, putbint, putbdouble, putbfloat, putbbyte, putbword; |
66 |
> |
static putfunc_t putcascii, putcint, putcdouble, putcfloat, putcbyte, putcword; |
67 |
> |
static putfunc_t putpascii, putpint, putpdouble, putpfloat, putpbyte, putpword; |
68 |
> |
|
69 |
> |
static void set_io(void); |
70 |
> |
static void pixtoval(void); |
71 |
> |
static void valtopix(void); |
72 |
> |
|
73 |
> |
|
74 |
> |
static double |
75 |
> |
rgb_bright( |
76 |
> |
COLOR clr |
77 |
> |
) |
78 |
|
{ |
79 |
|
return(bright(clr)); |
80 |
|
} |
81 |
|
|
82 |
< |
double |
83 |
< |
xyz_bright(clr) |
84 |
< |
COLOR clr; |
82 |
> |
static double |
83 |
> |
xyz_bright( |
84 |
> |
COLOR clr |
85 |
> |
) |
86 |
|
{ |
87 |
|
return(clr[CIEY]); |
88 |
|
} |
89 |
|
|
90 |
< |
double (*mybright)() = &rgb_bright; |
91 |
< |
|
92 |
< |
|
93 |
< |
main(argc, argv) |
94 |
< |
int argc; |
90 |
< |
char **argv; |
90 |
> |
int |
91 |
> |
main( |
92 |
> |
int argc, |
93 |
> |
char **argv |
94 |
> |
) |
95 |
|
{ |
96 |
< |
extern int checkhead(); |
97 |
< |
extern long atol(); |
98 |
< |
double d, expval = 1.0; |
95 |
< |
int i; |
96 |
> |
const char *inpmode = "r"; |
97 |
> |
double d, expval = 1.0; |
98 |
> |
int i; |
99 |
|
|
100 |
|
progname = argv[0]; |
101 |
+ |
mybright = &rgb_bright; /* default */ |
102 |
|
|
103 |
|
for (i = 1; i < argc; i++) |
104 |
|
if (argv[i][0] == '-' || argv[i][0] == '+') |
150 |
|
case 'b': /* brightness values */ |
151 |
|
putprim = argv[i][0] == '-' ? BRIGHT : ALL; |
152 |
|
break; |
153 |
< |
case 'p': /* put primary */ |
153 |
> |
case 'p': /* primary controls */ |
154 |
|
switch (argv[i][2]) { |
155 |
+ |
/* these two options affect -r conversion */ |
156 |
+ |
case '\0': |
157 |
+ |
myprims[RED][CIEX] = atof(argv[++i]); |
158 |
+ |
myprims[RED][CIEY] = atof(argv[++i]); |
159 |
+ |
myprims[GRN][CIEX] = atof(argv[++i]); |
160 |
+ |
myprims[GRN][CIEY] = atof(argv[++i]); |
161 |
+ |
myprims[BLU][CIEX] = atof(argv[++i]); |
162 |
+ |
myprims[BLU][CIEY] = atof(argv[++i]); |
163 |
+ |
myprims[WHT][CIEX] = atof(argv[++i]); |
164 |
+ |
myprims[WHT][CIEY] = atof(argv[++i]); |
165 |
+ |
outprims = myprims; |
166 |
+ |
break; |
167 |
+ |
case 'x': case 'X': outprims = NULL; break; |
168 |
+ |
/* the following options affect +r only */ |
169 |
|
case 'r': case 'R': putprim = RED; break; |
170 |
|
case 'g': case 'G': putprim = GRN; break; |
171 |
|
case 'b': case 'B': putprim = BLU; break; |
196 |
|
format = 'w'; |
197 |
|
fmtid = "16-bit"; |
198 |
|
break; |
199 |
+ |
case 'F': /* swapped floats */ |
200 |
+ |
swapbytes = 1; |
201 |
|
case 'f': /* float */ |
202 |
|
dataonly = 1; |
203 |
|
format = 'f'; |
204 |
|
fmtid = "float"; |
205 |
|
break; |
206 |
+ |
case 'D': /* swapped doubles */ |
207 |
+ |
swapbytes = 1; |
208 |
|
case 'd': /* double */ |
209 |
|
dataonly = 1; |
210 |
|
format = 'd'; |
240 |
|
else |
241 |
|
break; |
242 |
|
/* recognize special formats */ |
243 |
< |
if (dataonly && format == 'b') |
244 |
< |
if (brightonly) |
223 |
< |
fmtid = "8-bit_grey"; |
224 |
< |
else |
243 |
> |
if (dataonly && format == 'b') { |
244 |
> |
if (putprim == ALL) |
245 |
|
fmtid = "24-bit_rgb"; |
226 |
– |
if (dataonly && format == 'w') |
227 |
– |
if (brightonly) |
228 |
– |
fmtid = "16-bit_grey"; |
246 |
|
else |
247 |
+ |
fmtid = "8-bit_grey"; |
248 |
+ |
} |
249 |
+ |
if (dataonly && format == 'w') { |
250 |
+ |
if (putprim == ALL) |
251 |
|
fmtid = "48-bit_rgb"; |
252 |
+ |
else |
253 |
+ |
fmtid = "16-bit_grey"; |
254 |
+ |
} |
255 |
+ |
if (!reverse || (format != 'a') & (format != 'i')) |
256 |
+ |
inpmode = "rb"; |
257 |
|
/* assign reverse ordering */ |
258 |
|
rord[ord[0]] = 0; |
259 |
|
rord[ord[1]] = 1; |
260 |
|
rord[ord[2]] = 2; |
261 |
|
/* get input */ |
262 |
|
if (i == argc) { |
263 |
+ |
long n = skipbytes; |
264 |
+ |
if (inpmode[1] == 'b') |
265 |
+ |
SET_FILE_BINARY(stdin); |
266 |
+ |
while (n-- > 0) |
267 |
+ |
if (getchar() == EOF) { |
268 |
+ |
fprintf(stderr, |
269 |
+ |
"%s: cannot skip %ld bytes on standard input\n", |
270 |
+ |
progname, skipbytes); |
271 |
+ |
quit(1); |
272 |
+ |
} |
273 |
|
fin = stdin; |
274 |
|
} else if (i < argc) { |
275 |
< |
if ((fin = fopen(argv[i], "r")) == NULL) { |
275 |
> |
if ((fin = fopen(argv[i], inpmode)) == NULL) { |
276 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
277 |
|
progname, argv[i]); |
278 |
|
quit(1); |
279 |
|
} |
280 |
< |
if (reverse && !brightonly && i == argc-3) { |
281 |
< |
if ((fin2 = fopen(argv[i+1], "r")) == NULL) { |
280 |
> |
if (reverse && putprim != BRIGHT && i == argc-3) { |
281 |
> |
if ((fin2 = fopen(argv[i+1], inpmode)) == NULL) { |
282 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
283 |
|
progname, argv[i+1]); |
284 |
|
quit(1); |
285 |
|
} |
286 |
< |
if ((fin3 = fopen(argv[i+2], "r")) == NULL) { |
286 |
> |
if ((fin3 = fopen(argv[i+2], inpmode)) == NULL) { |
287 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
288 |
|
progname, argv[i+2]); |
289 |
|
quit(1); |
291 |
|
interleave = -1; |
292 |
|
} else if (i != argc-1) |
293 |
|
fin = NULL; |
294 |
< |
if (reverse && !brightonly && !interleave) { |
295 |
< |
fin2 = fopen(argv[i], "r"); |
296 |
< |
fin3 = fopen(argv[i], "r"); |
294 |
> |
if (reverse && putprim != BRIGHT && !interleave) { |
295 |
> |
fin2 = fopen(argv[i], inpmode); |
296 |
> |
fin3 = fopen(argv[i], inpmode); |
297 |
|
} |
298 |
< |
if (skipbytes && (fseek(fin, skipbytes, 0) || (fin2 != NULL && |
299 |
< |
(fseek(fin2, skipbytes, 0) || |
300 |
< |
fseek(fin3, skipbytes, 0))))) { |
298 |
> |
if (skipbytes && (fseek(fin, skipbytes, SEEK_SET) || (fin2 != NULL && |
299 |
> |
fseek(fin2, skipbytes, SEEK_SET) | |
300 |
> |
fseek(fin3, skipbytes, SEEK_SET)))) { |
301 |
|
fprintf(stderr, "%s: cannot skip %ld bytes on input\n", |
302 |
|
progname, skipbytes); |
303 |
|
quit(1); |
309 |
|
} |
310 |
|
|
311 |
|
if (reverse) { |
312 |
< |
#ifdef MSDOS |
277 |
< |
setmode(fileno(stdout), O_BINARY); |
278 |
< |
if (format != 'a' && format != 'i') |
279 |
< |
setmode(fileno(fin), O_BINARY); |
280 |
< |
#endif |
312 |
> |
SET_FILE_BINARY(stdout); |
313 |
|
/* get header */ |
314 |
|
if (header) { |
315 |
< |
if (checkheader(fin, fmtid, stdout) < 0) { |
316 |
< |
fprintf(stderr, "%s: wrong input format\n", |
317 |
< |
progname); |
315 |
> |
getheader(fin, checkhead, stdout); |
316 |
> |
if (wrongformat) { |
317 |
> |
fprintf(stderr, "%s: wrong input format (expected %s)\n", |
318 |
> |
progname, fmtid); |
319 |
|
quit(1); |
320 |
|
} |
321 |
|
if (fin2 != NULL) { |
349 |
|
printargs(i, argv, stdout); |
350 |
|
if (expval < .99 || expval > 1.01) |
351 |
|
fputexpos(expval, stdout); |
352 |
< |
fputformat(COLRFMT, stdout); |
352 |
> |
if (outprims != NULL) { |
353 |
> |
if (outprims != stdprims) |
354 |
> |
fputprims(outprims, stdout); |
355 |
> |
fputformat(COLRFMT, stdout); |
356 |
> |
} else /* XYZ data */ |
357 |
> |
fputformat(CIEFMT, stdout); |
358 |
|
putchar('\n'); |
359 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
360 |
|
valtopix(); |
361 |
|
} else { |
362 |
< |
#ifdef MSDOS |
363 |
< |
setmode(fileno(fin), O_BINARY); |
326 |
< |
if (format != 'a' && format != 'i') |
327 |
< |
setmode(fileno(stdout), O_BINARY); |
328 |
< |
#endif |
362 |
> |
if ((format != 'a') & (format != 'i')) |
363 |
> |
SET_FILE_BINARY(stdout); |
364 |
|
/* get header */ |
365 |
< |
getheader(fin, checkhead, NULL); |
365 |
> |
getheader(fin, checkhead, header ? stdout : (FILE *)NULL); |
366 |
|
if (wrongformat) { |
367 |
|
fprintf(stderr, |
368 |
|
"%s: input not a Radiance RGBE picture\n", |
377 |
|
printargs(i, argv, stdout); |
378 |
|
if (expval < .99 || expval > 1.01) |
379 |
|
fputexpos(expval, stdout); |
380 |
+ |
if (swapbytes) { |
381 |
+ |
if (nativebigendian()) |
382 |
+ |
puts("BigEndian=0"); |
383 |
+ |
else |
384 |
+ |
puts("BigEndian=1"); |
385 |
+ |
} else if ((format != 'a') & (format != 'i')) |
386 |
+ |
fputendian(stdout); |
387 |
|
fputformat(fmtid, stdout); |
388 |
|
putchar('\n'); |
389 |
|
} |
393 |
|
} |
394 |
|
|
395 |
|
quit(0); |
396 |
+ |
return 0; /* pro forma return */ |
397 |
|
} |
398 |
|
|
399 |
|
|
400 |
< |
int |
401 |
< |
checkhead(line) /* deal with line from header */ |
402 |
< |
char *line; |
400 |
> |
static int |
401 |
> |
checkhead( /* deal with line from header */ |
402 |
> |
char *line, |
403 |
> |
void *p |
404 |
> |
) |
405 |
|
{ |
406 |
< |
char fmt[32]; |
406 |
> |
FILE *fout = (FILE *)p; |
407 |
> |
char fmt[MAXFMTLEN]; |
408 |
|
double d; |
409 |
|
COLOR ctmp; |
410 |
+ |
int rv; |
411 |
|
|
412 |
|
if (formatval(fmt, line)) { |
413 |
< |
if (!strcmp(fmt, CIEFMT)) { |
413 |
> |
if (reverse) |
414 |
> |
wrongformat = strcmp(fmt, fmtid); |
415 |
> |
else if (!strcmp(fmt, CIEFMT)) |
416 |
|
mybright = &xyz_bright; |
417 |
< |
if (original) { |
369 |
< |
scalecolor(exposure, 1./WHTEFFICACY); |
370 |
< |
doexposure++; |
371 |
< |
} |
372 |
< |
} else if (!strcmp(fmt, COLRFMT)) |
417 |
> |
else if (!strcmp(fmt, COLRFMT)) |
418 |
|
mybright = &rgb_bright; |
419 |
|
else |
420 |
|
wrongformat++; |
428 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
429 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
430 |
|
doexposure++; |
431 |
< |
} else if (header) |
432 |
< |
fputs(line, stdout); |
431 |
> |
} else if ((rv = isbigendian(line)) >= 0) { |
432 |
> |
if (reverse) |
433 |
> |
swapbytes = (nativebigendian() != rv); |
434 |
> |
} else if (fout != NULL) |
435 |
> |
fputs(line, fout); |
436 |
|
return(0); |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
< |
pixtoval() /* convert picture to values */ |
440 |
> |
static void |
441 |
> |
pixtoval(void) /* convert picture to values */ |
442 |
|
{ |
443 |
< |
register COLOR *scanln; |
443 |
> |
COLOR *scanln; |
444 |
|
int dogamma; |
445 |
|
COLOR lastc; |
446 |
< |
FLOAT hv[2]; |
446 |
> |
RREAL hv[2]; |
447 |
|
int startprim, endprim; |
448 |
|
long startpos; |
449 |
< |
int y; |
401 |
< |
register int x; |
449 |
> |
int x, y; |
450 |
|
|
451 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
452 |
|
if (scanln == NULL) { |
454 |
|
quit(1); |
455 |
|
} |
456 |
|
dogamma = gamcor < .95 || gamcor > 1.05; |
457 |
< |
if (putprim == ALL && !interleave) { |
457 |
> |
if ((putprim == ALL) & !interleave) { |
458 |
|
startprim = RED; endprim = BLU; |
459 |
|
startpos = ftell(fin); |
460 |
|
} else { |
461 |
|
startprim = putprim; endprim = putprim; |
462 |
|
} |
463 |
|
for (putprim = startprim; putprim <= endprim; putprim++) { |
464 |
< |
if (putprim != startprim && fseek(fin, startpos, 0)) { |
464 |
> |
if (putprim != startprim && fseek(fin, startpos, SEEK_SET)) { |
465 |
|
fprintf(stderr, "%s: seek error on input file\n", |
466 |
|
progname); |
467 |
|
quit(1); |
474 |
|
quit(1); |
475 |
|
} |
476 |
|
for (x = 0; x < scanlen(&picres); x++) { |
477 |
< |
if (uniq) |
477 |
> |
if (uniq) { |
478 |
|
if ( colval(scanln[x],RED) == |
479 |
|
colval(lastc,RED) && |
480 |
|
colval(scanln[x],GRN) == |
484 |
|
continue; |
485 |
|
else |
486 |
|
copycolor(lastc, scanln[x]); |
487 |
+ |
} |
488 |
|
if (doexposure) |
489 |
|
multcolor(scanln[x], exposure); |
490 |
|
if (dogamma) |
510 |
|
} |
511 |
|
|
512 |
|
|
513 |
< |
valtopix() /* convert values to a pixel file */ |
513 |
> |
static void |
514 |
> |
valtopix(void) /* convert values to a pixel file */ |
515 |
|
{ |
516 |
< |
int dogamma; |
517 |
< |
register COLOR *scanln; |
518 |
< |
int y; |
519 |
< |
register int x; |
516 |
> |
int dogamma; |
517 |
> |
COLOR *scanln; |
518 |
> |
COLR rgbe; |
519 |
> |
int x, y; |
520 |
|
|
521 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
522 |
|
if (scanln == NULL) { |
545 |
|
pow(colval(scanln[x],BLU), gamcor)); |
546 |
|
if (doexposure) |
547 |
|
multcolor(scanln[x], exposure); |
548 |
+ |
if (uniq) { /* uncompressed? */ |
549 |
+ |
setcolr(rgbe, scanln[x][RED], |
550 |
+ |
scanln[x][GRN], |
551 |
+ |
scanln[x][BLU]); |
552 |
+ |
if (putbinary(rgbe, sizeof(COLR), 1, stdout) != 1) |
553 |
+ |
goto writerr; |
554 |
+ |
} |
555 |
|
} |
556 |
< |
if (fwritescan(scanln, scanlen(&picres), stdout) < 0) { |
557 |
< |
fprintf(stderr, "%s: write error\n", progname); |
558 |
< |
quit(1); |
502 |
< |
} |
556 |
> |
/* write scan if compressed */ |
557 |
> |
if (!uniq && fwritescan(scanln, scanlen(&picres), stdout) < 0) |
558 |
> |
goto writerr; |
559 |
|
} |
560 |
|
free((void *)scanln); |
561 |
+ |
return; |
562 |
+ |
writerr: |
563 |
+ |
fprintf(stderr, "%s: write error\n", progname); |
564 |
+ |
quit(1); |
565 |
|
} |
566 |
|
|
567 |
|
|
573 |
|
} |
574 |
|
|
575 |
|
|
576 |
< |
swap16(wp, n) /* swap n 16-bit words */ |
577 |
< |
register uint16 *wp; |
578 |
< |
int n; |
576 |
> |
static int |
577 |
> |
getcascii( /* get an ascii color value from stream(s) */ |
578 |
> |
COLOR col |
579 |
> |
) |
580 |
|
{ |
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 |
– |
{ |
581 |
|
double vd[3]; |
582 |
|
|
583 |
|
if (fin2 == NULL) { |
594 |
|
} |
595 |
|
|
596 |
|
|
597 |
< |
getcdouble(col) /* get a double color value from stream(s) */ |
598 |
< |
COLOR col; |
597 |
> |
static int |
598 |
> |
getcdouble( /* get a double color value from stream(s) */ |
599 |
> |
COLOR col |
600 |
> |
) |
601 |
|
{ |
602 |
|
double vd[3]; |
603 |
|
|
604 |
|
if (fin2 == NULL) { |
605 |
< |
if (fread((char *)vd, sizeof(double), 3, fin) != 3) |
605 |
> |
if (getbinary(vd, sizeof(double), 3, fin) != 3) |
606 |
|
return(-1); |
607 |
|
} else { |
608 |
< |
if (fread((char *)vd, sizeof(double), 1, fin) != 1 || |
609 |
< |
fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 || |
610 |
< |
fread((char *)(vd+2), sizeof(double), 1, fin3) != 1) |
608 |
> |
if (getbinary(vd, sizeof(double), 1, fin) != 1 || |
609 |
> |
getbinary(vd+1, sizeof(double), 1, fin2) != 1 || |
610 |
> |
getbinary(vd+2, sizeof(double), 1, fin3) != 1) |
611 |
|
return(-1); |
612 |
|
} |
613 |
+ |
if (swapbytes) |
614 |
+ |
swap64((char *)vd, 3); |
615 |
|
setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]); |
616 |
|
return(0); |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
< |
getcfloat(col) /* get a float color value from stream(s) */ |
621 |
< |
COLOR col; |
620 |
> |
static int |
621 |
> |
getcfloat( /* get a float color value from stream(s) */ |
622 |
> |
COLOR col |
623 |
> |
) |
624 |
|
{ |
625 |
|
float vf[3]; |
626 |
|
|
627 |
|
if (fin2 == NULL) { |
628 |
< |
if (fread((char *)vf, sizeof(float), 3, fin) != 3) |
628 |
> |
if (getbinary(vf, sizeof(float), 3, fin) != 3) |
629 |
|
return(-1); |
630 |
|
} else { |
631 |
< |
if (fread((char *)vf, sizeof(float), 1, fin) != 1 || |
632 |
< |
fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 || |
633 |
< |
fread((char *)(vf+2), sizeof(float), 1, fin3) != 1) |
631 |
> |
if (getbinary(vf, sizeof(float), 1, fin) != 1 || |
632 |
> |
getbinary(vf+1, sizeof(float), 1, fin2) != 1 || |
633 |
> |
getbinary(vf+2, sizeof(float), 1, fin3) != 1) |
634 |
|
return(-1); |
635 |
|
} |
636 |
+ |
if (swapbytes) |
637 |
+ |
swap32((char *)vf, 3); |
638 |
|
setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]); |
639 |
|
return(0); |
640 |
|
} |
641 |
|
|
642 |
|
|
643 |
< |
getcint(col) /* get an int color value from stream(s) */ |
644 |
< |
COLOR col; |
643 |
> |
static int |
644 |
> |
getcint( /* get an int color value from stream(s) */ |
645 |
> |
COLOR col |
646 |
> |
) |
647 |
|
{ |
648 |
|
int vi[3]; |
649 |
|
|
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
< |
getcbyte(col) /* get a byte color value from stream(s) */ |
666 |
< |
COLOR col; |
665 |
> |
static int |
666 |
> |
getcbyte( /* get a byte color value from stream(s) */ |
667 |
> |
COLOR col |
668 |
> |
) |
669 |
|
{ |
670 |
< |
BYTE vb[3]; |
670 |
> |
uby8 vb[3]; |
671 |
|
|
672 |
|
if (fin2 == NULL) { |
673 |
< |
if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3) |
673 |
> |
if (getbinary(vb, sizeof(uby8), 3, fin) != 3) |
674 |
|
return(-1); |
675 |
|
} else { |
676 |
< |
if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 || |
677 |
< |
fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 || |
678 |
< |
fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1) |
676 |
> |
if (getbinary(vb, sizeof(uby8), 1, fin) != 1 || |
677 |
> |
getbinary(vb+1, sizeof(uby8), 1, fin2) != 1 || |
678 |
> |
getbinary(vb+2, sizeof(uby8), 1, fin3) != 1) |
679 |
|
return(-1); |
680 |
|
} |
681 |
|
setcolor(col, (vb[rord[RED]]+.5)/256., |
684 |
|
} |
685 |
|
|
686 |
|
|
687 |
< |
getcword(col) /* get a 16-bit color value from stream(s) */ |
688 |
< |
COLOR col; |
687 |
> |
static int |
688 |
> |
getcword( /* get a 16-bit color value from stream(s) */ |
689 |
> |
COLOR col |
690 |
> |
) |
691 |
|
{ |
692 |
|
uint16 vw[3]; |
693 |
|
|
694 |
|
if (fin2 == NULL) { |
695 |
< |
if (fread((char *)vw, sizeof(uint16), 3, fin) != 3) |
695 |
> |
if (getbinary(vw, sizeof(uint16), 3, fin) != 3) |
696 |
|
return(-1); |
697 |
|
} else { |
698 |
< |
if (fread((char *)vw, sizeof(uint16), 1, fin) != 1 || |
699 |
< |
fread((char *)(vw+1), sizeof(uint16), 1, fin2) != 1 || |
700 |
< |
fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1) |
698 |
> |
if (getbinary(vw, sizeof(uint16), 1, fin) != 1 || |
699 |
> |
getbinary(vw+1, sizeof(uint16), 1, fin2) != 1 || |
700 |
> |
getbinary(vw+2, sizeof(uint16), 1, fin3) != 1) |
701 |
|
return(-1); |
702 |
|
} |
703 |
|
if (swapbytes) |
704 |
< |
swap16(vw, 3); |
704 |
> |
swap16((char *)vw, 3); |
705 |
|
setcolor(col, (vw[rord[RED]]+.5)/65536., |
706 |
|
(vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.); |
707 |
|
return(0); |
708 |
|
} |
709 |
|
|
710 |
|
|
711 |
< |
getbascii(col) /* get an ascii brightness value from fin */ |
712 |
< |
COLOR col; |
711 |
> |
static int |
712 |
> |
getbascii( /* get an ascii brightness value from fin */ |
713 |
> |
COLOR col |
714 |
> |
) |
715 |
|
{ |
716 |
|
double vd; |
717 |
|
|
722 |
|
} |
723 |
|
|
724 |
|
|
725 |
< |
getbdouble(col) /* get a double brightness value from fin */ |
726 |
< |
COLOR col; |
725 |
> |
static int |
726 |
> |
getbdouble( /* get a double brightness value from fin */ |
727 |
> |
COLOR col |
728 |
> |
) |
729 |
|
{ |
730 |
|
double vd; |
731 |
|
|
732 |
< |
if (fread((char *)&vd, sizeof(double), 1, fin) != 1) |
732 |
> |
if (getbinary(&vd, sizeof(double), 1, fin) != 1) |
733 |
|
return(-1); |
734 |
+ |
if (swapbytes) |
735 |
+ |
swap64((char *)&vd, 1); |
736 |
|
setcolor(col, vd, vd, vd); |
737 |
|
return(0); |
738 |
|
} |
739 |
|
|
740 |
|
|
741 |
< |
getbfloat(col) /* get a float brightness value from fin */ |
742 |
< |
COLOR col; |
741 |
> |
static int |
742 |
> |
getbfloat( /* get a float brightness value from fin */ |
743 |
> |
COLOR col |
744 |
> |
) |
745 |
|
{ |
746 |
|
float vf; |
747 |
|
|
748 |
< |
if (fread((char *)&vf, sizeof(float), 1, fin) != 1) |
748 |
> |
if (getbinary(&vf, sizeof(float), 1, fin) != 1) |
749 |
|
return(-1); |
750 |
+ |
if (swapbytes) |
751 |
+ |
swap32((char *)&vf, 1); |
752 |
|
setcolor(col, vf, vf, vf); |
753 |
|
return(0); |
754 |
|
} |
755 |
|
|
756 |
|
|
757 |
< |
getbint(col) /* get an int brightness value from fin */ |
758 |
< |
COLOR col; |
757 |
> |
static int |
758 |
> |
getbint( /* get an int brightness value from fin */ |
759 |
> |
COLOR col |
760 |
> |
) |
761 |
|
{ |
762 |
|
int vi; |
763 |
|
double d; |
770 |
|
} |
771 |
|
|
772 |
|
|
773 |
< |
getbbyte(col) /* get a byte brightness value from fin */ |
774 |
< |
COLOR col; |
773 |
> |
static int |
774 |
> |
getbbyte( /* get a byte brightness value from fin */ |
775 |
> |
COLOR col |
776 |
> |
) |
777 |
|
{ |
778 |
< |
BYTE vb; |
778 |
> |
uby8 vb; |
779 |
|
double d; |
780 |
|
|
781 |
< |
if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1) |
781 |
> |
if (getbinary(&vb, sizeof(uby8), 1, fin) != 1) |
782 |
|
return(-1); |
783 |
|
d = (vb+.5)/256.; |
784 |
|
setcolor(col, d, d, d); |
786 |
|
} |
787 |
|
|
788 |
|
|
789 |
< |
getbword(col) /* get a 16-bit brightness value from fin */ |
790 |
< |
COLOR col; |
789 |
> |
static int |
790 |
> |
getbword( /* get a 16-bit brightness value from fin */ |
791 |
> |
COLOR col |
792 |
> |
) |
793 |
|
{ |
794 |
|
uint16 vw; |
795 |
|
double d; |
796 |
|
|
797 |
< |
if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1) |
797 |
> |
if (getbinary(&vw, sizeof(uint16), 1, fin) != 1) |
798 |
|
return(-1); |
799 |
|
if (swapbytes) |
800 |
< |
swap16(&vw, 1); |
800 |
> |
swap16((char *)&vw, 1); |
801 |
|
d = (vw+.5)/65536.; |
802 |
|
setcolor(col, d, d, d); |
803 |
|
return(0); |
804 |
|
} |
805 |
|
|
806 |
|
|
807 |
< |
putcascii(col) /* put an ascii color to stdout */ |
808 |
< |
COLOR col; |
807 |
> |
static int |
808 |
> |
putcascii( /* put an ascii color to stdout */ |
809 |
> |
COLOR col |
810 |
> |
) |
811 |
|
{ |
812 |
|
fprintf(stdout, "%15.3e %15.3e %15.3e\n", |
813 |
|
colval(col,ord[0]), |
818 |
|
} |
819 |
|
|
820 |
|
|
821 |
< |
putcfloat(col) /* put a float color to stdout */ |
822 |
< |
COLOR col; |
821 |
> |
static int |
822 |
> |
putcfloat( /* put a float color to stdout */ |
823 |
> |
COLOR col |
824 |
> |
) |
825 |
|
{ |
826 |
|
float vf[3]; |
827 |
|
|
828 |
|
vf[0] = colval(col,ord[0]); |
829 |
|
vf[1] = colval(col,ord[1]); |
830 |
|
vf[2] = colval(col,ord[2]); |
831 |
< |
fwrite((char *)vf, sizeof(float), 3, stdout); |
831 |
> |
if (swapbytes) |
832 |
> |
swap32((char *)vf, 3); |
833 |
> |
putbinary(vf, sizeof(float), 3, stdout); |
834 |
|
|
835 |
|
return(ferror(stdout) ? -1 : 0); |
836 |
|
} |
837 |
|
|
838 |
|
|
839 |
< |
putcdouble(col) /* put a double color to stdout */ |
840 |
< |
COLOR col; |
839 |
> |
static int |
840 |
> |
putcdouble( /* put a double color to stdout */ |
841 |
> |
COLOR col |
842 |
> |
) |
843 |
|
{ |
844 |
|
double vd[3]; |
845 |
|
|
846 |
|
vd[0] = colval(col,ord[0]); |
847 |
|
vd[1] = colval(col,ord[1]); |
848 |
|
vd[2] = colval(col,ord[2]); |
849 |
< |
fwrite((char *)vd, sizeof(double), 3, stdout); |
849 |
> |
if (swapbytes) |
850 |
> |
swap64((char *)vd, 3); |
851 |
> |
putbinary(vd, sizeof(double), 3, stdout); |
852 |
|
|
853 |
|
return(ferror(stdout) ? -1 : 0); |
854 |
|
} |
855 |
|
|
856 |
|
|
857 |
< |
putcint(col) /* put an int color to stdout */ |
858 |
< |
COLOR col; |
857 |
> |
static int |
858 |
> |
putcint( /* put an int color to stdout */ |
859 |
> |
COLOR col |
860 |
> |
) |
861 |
|
{ |
862 |
|
fprintf(stdout, "%d %d %d\n", |
863 |
|
(int)(colval(col,ord[0])*256.), |
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
< |
putcbyte(col) /* put a byte color to stdout */ |
872 |
< |
COLOR col; |
871 |
> |
static int |
872 |
> |
putcbyte( /* put a byte color to stdout */ |
873 |
> |
COLOR col |
874 |
> |
) |
875 |
|
{ |
876 |
|
long i; |
877 |
< |
BYTE vb[3]; |
877 |
> |
uby8 vb[3]; |
878 |
|
|
879 |
|
i = colval(col,ord[0])*256.; |
880 |
|
vb[0] = min(i,255); |
882 |
|
vb[1] = min(i,255); |
883 |
|
i = colval(col,ord[2])*256.; |
884 |
|
vb[2] = min(i,255); |
885 |
< |
fwrite((char *)vb, sizeof(BYTE), 3, stdout); |
885 |
> |
putbinary(vb, sizeof(uby8), 3, stdout); |
886 |
|
|
887 |
|
return(ferror(stdout) ? -1 : 0); |
888 |
|
} |
889 |
|
|
890 |
|
|
891 |
< |
putcword(col) /* put a 16-bit color to stdout */ |
892 |
< |
COLOR col; |
891 |
> |
static int |
892 |
> |
putcword( /* put a 16-bit color to stdout */ |
893 |
> |
COLOR col |
894 |
> |
) |
895 |
|
{ |
896 |
|
long i; |
897 |
|
uint16 vw[3]; |
903 |
|
i = colval(col,ord[2])*65536.; |
904 |
|
vw[2] = min(i,65535); |
905 |
|
if (swapbytes) |
906 |
< |
swap16(vw, 3); |
907 |
< |
fwrite((char *)vw, sizeof(uint16), 3, stdout); |
906 |
> |
swap16((char *)vw, 3); |
907 |
> |
putbinary(vw, sizeof(uint16), 3, stdout); |
908 |
|
|
909 |
|
return(ferror(stdout) ? -1 : 0); |
910 |
|
} |
911 |
|
|
912 |
|
|
913 |
< |
putbascii(col) /* put an ascii brightness to stdout */ |
914 |
< |
COLOR col; |
913 |
> |
static int |
914 |
> |
putbascii( /* put an ascii brightness to stdout */ |
915 |
> |
COLOR col |
916 |
> |
) |
917 |
|
{ |
918 |
|
fprintf(stdout, "%15.3e\n", (*mybright)(col)); |
919 |
|
|
921 |
|
} |
922 |
|
|
923 |
|
|
924 |
< |
putbfloat(col) /* put a float brightness to stdout */ |
925 |
< |
COLOR col; |
924 |
> |
static int |
925 |
> |
putbfloat( /* put a float brightness to stdout */ |
926 |
> |
COLOR col |
927 |
> |
) |
928 |
|
{ |
929 |
|
float vf; |
930 |
|
|
931 |
|
vf = (*mybright)(col); |
932 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
932 |
> |
if (swapbytes) |
933 |
> |
swap32((char *)&vf, 1); |
934 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
935 |
|
|
936 |
|
return(ferror(stdout) ? -1 : 0); |
937 |
|
} |
938 |
|
|
939 |
|
|
940 |
< |
putbdouble(col) /* put a double brightness to stdout */ |
941 |
< |
COLOR col; |
940 |
> |
static int |
941 |
> |
putbdouble( /* put a double brightness to stdout */ |
942 |
> |
COLOR col |
943 |
> |
) |
944 |
|
{ |
945 |
|
double vd; |
946 |
|
|
947 |
|
vd = (*mybright)(col); |
948 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
948 |
> |
if (swapbytes) |
949 |
> |
swap64((char *)&vd, 1); |
950 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
951 |
|
|
952 |
|
return(ferror(stdout) ? -1 : 0); |
953 |
|
} |
954 |
|
|
955 |
|
|
956 |
< |
putbint(col) /* put an int brightness to stdout */ |
957 |
< |
COLOR col; |
956 |
> |
static int |
957 |
> |
putbint( /* put an int brightness to stdout */ |
958 |
> |
COLOR col |
959 |
> |
) |
960 |
|
{ |
961 |
|
fprintf(stdout, "%d\n", (int)((*mybright)(col)*256.)); |
962 |
|
|
964 |
|
} |
965 |
|
|
966 |
|
|
967 |
< |
putbbyte(col) /* put a byte brightness to stdout */ |
968 |
< |
COLOR col; |
967 |
> |
static int |
968 |
> |
putbbyte( /* put a byte brightness to stdout */ |
969 |
> |
COLOR col |
970 |
> |
) |
971 |
|
{ |
972 |
< |
register int i; |
973 |
< |
BYTE vb; |
972 |
> |
int i; |
973 |
> |
uby8 vb; |
974 |
|
|
975 |
|
i = (*mybright)(col)*256.; |
976 |
|
vb = min(i,255); |
977 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
977 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
978 |
|
|
979 |
|
return(ferror(stdout) ? -1 : 0); |
980 |
|
} |
981 |
|
|
982 |
|
|
983 |
< |
putbword(col) /* put a 16-bit brightness to stdout */ |
984 |
< |
COLOR col; |
983 |
> |
static int |
984 |
> |
putbword( /* put a 16-bit brightness to stdout */ |
985 |
> |
COLOR col |
986 |
> |
) |
987 |
|
{ |
988 |
|
long i; |
989 |
|
uint16 vw; |
991 |
|
i = (*mybright)(col)*65536.; |
992 |
|
vw = min(i,65535); |
993 |
|
if (swapbytes) |
994 |
< |
swap16(&vw, 1); |
995 |
< |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
994 |
> |
swap16((char *)&vw, 1); |
995 |
> |
putbinary(&vw, sizeof(uint16), 1, stdout); |
996 |
|
|
997 |
|
return(ferror(stdout) ? -1 : 0); |
998 |
|
} |
999 |
|
|
1000 |
|
|
1001 |
< |
putpascii(col) /* put an ascii primary to stdout */ |
1002 |
< |
COLOR col; |
1001 |
> |
static int |
1002 |
> |
putpascii( /* put an ascii primary to stdout */ |
1003 |
> |
COLOR col |
1004 |
> |
) |
1005 |
|
{ |
1006 |
|
fprintf(stdout, "%15.3e\n", colval(col,putprim)); |
1007 |
|
|
1009 |
|
} |
1010 |
|
|
1011 |
|
|
1012 |
< |
putpfloat(col) /* put a float primary to stdout */ |
1013 |
< |
COLOR col; |
1012 |
> |
static int |
1013 |
> |
putpfloat( /* put a float primary to stdout */ |
1014 |
> |
COLOR col |
1015 |
> |
) |
1016 |
|
{ |
1017 |
|
float vf; |
1018 |
|
|
1019 |
|
vf = colval(col,putprim); |
1020 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
1020 |
> |
if (swapbytes) |
1021 |
> |
swap32((char *)&vf, 1); |
1022 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
1023 |
|
|
1024 |
|
return(ferror(stdout) ? -1 : 0); |
1025 |
|
} |
1026 |
|
|
1027 |
|
|
1028 |
< |
putpdouble(col) /* put a double primary to stdout */ |
1029 |
< |
COLOR col; |
1028 |
> |
static int |
1029 |
> |
putpdouble( /* put a double primary to stdout */ |
1030 |
> |
COLOR col |
1031 |
> |
) |
1032 |
|
{ |
1033 |
|
double vd; |
1034 |
|
|
1035 |
|
vd = colval(col,putprim); |
1036 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
1036 |
> |
if (swapbytes) |
1037 |
> |
swap64((char *)&vd, 1); |
1038 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
1039 |
|
|
1040 |
|
return(ferror(stdout) ? -1 : 0); |
1041 |
|
} |
1042 |
|
|
1043 |
|
|
1044 |
< |
putpint(col) /* put an int primary to stdout */ |
1045 |
< |
COLOR col; |
1044 |
> |
static int |
1045 |
> |
putpint( /* put an int primary to stdout */ |
1046 |
> |
COLOR col |
1047 |
> |
) |
1048 |
|
{ |
1049 |
|
fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.)); |
1050 |
|
|
1052 |
|
} |
1053 |
|
|
1054 |
|
|
1055 |
< |
putpbyte(col) /* put a byte primary to stdout */ |
1056 |
< |
COLOR col; |
1055 |
> |
static int |
1056 |
> |
putpbyte( /* put a byte primary to stdout */ |
1057 |
> |
COLOR col |
1058 |
> |
) |
1059 |
|
{ |
1060 |
|
long i; |
1061 |
< |
BYTE vb; |
1061 |
> |
uby8 vb; |
1062 |
|
|
1063 |
|
i = colval(col,putprim)*256.; |
1064 |
|
vb = min(i,255); |
1065 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
1065 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
1066 |
|
|
1067 |
|
return(ferror(stdout) ? -1 : 0); |
1068 |
|
} |
1069 |
|
|
1070 |
|
|
1071 |
< |
putpword(col) /* put a 16-bit primary to stdout */ |
1072 |
< |
COLOR col; |
1071 |
> |
static int |
1072 |
> |
putpword( /* put a 16-bit primary to stdout */ |
1073 |
> |
COLOR col |
1074 |
> |
) |
1075 |
|
{ |
1076 |
|
long i; |
1077 |
|
uint16 vw; |
1079 |
|
i = colval(col,putprim)*65536.; |
1080 |
|
vw = min(i,65535); |
1081 |
|
if (swapbytes) |
1082 |
< |
swap16(&vw, 1); |
1083 |
< |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
1082 |
> |
swap16((char *)&vw, 1); |
1083 |
> |
putbinary(&vw, sizeof(uint16), 1, stdout); |
1084 |
|
|
1085 |
|
return(ferror(stdout) ? -1 : 0); |
1086 |
|
} |
1087 |
|
|
1088 |
|
|
1089 |
< |
set_io() /* set put and get functions */ |
1089 |
> |
static void |
1090 |
> |
set_io(void) /* set put and get functions */ |
1091 |
|
{ |
1092 |
|
switch (format) { |
1093 |
|
case 'a': /* ascii */ |
1122 |
|
if (fin2 == NULL) |
1123 |
|
goto namerr; |
1124 |
|
if (fseek(fin2, |
1125 |
< |
(long)sizeof(float)*picres.xr*picres.yr, 1)) |
1125 |
> |
(long)sizeof(float)*picres.xr*picres.yr, SEEK_CUR)) |
1126 |
|
goto seekerr; |
1127 |
|
if (fseek(fin3, |
1128 |
< |
(long)sizeof(float)*2*picres.xr*picres.yr, 1)) |
1128 |
> |
(long)sizeof(float)*2*picres.xr*picres.yr, SEEK_CUR)) |
1129 |
|
goto seekerr; |
1130 |
|
} |
1131 |
|
} |
1144 |
|
if (fin2 == NULL) |
1145 |
|
goto namerr; |
1146 |
|
if (fseek(fin2, |
1147 |
< |
(long)sizeof(double)*picres.xr*picres.yr, 1)) |
1147 |
> |
(long)sizeof(double)*picres.xr*picres.yr, SEEK_CUR)) |
1148 |
|
goto seekerr; |
1149 |
|
if (fseek(fin3, |
1150 |
< |
(long)sizeof(double)*2*picres.xr*picres.yr, 1)) |
1150 |
> |
(long)sizeof(double)*2*picres.xr*picres.yr, SEEK_CUR)) |
1151 |
|
goto seekerr; |
1152 |
|
} |
1153 |
|
} |
1184 |
|
if (fin2 == NULL) |
1185 |
|
goto namerr; |
1186 |
|
if (fseek(fin2, |
1187 |
< |
(long)sizeof(BYTE)*picres.xr*picres.yr, 1)) |
1187 |
> |
(long)sizeof(uby8)*picres.xr*picres.yr, SEEK_CUR)) |
1188 |
|
goto seekerr; |
1189 |
|
if (fseek(fin3, |
1190 |
< |
(long)sizeof(BYTE)*2*picres.xr*picres.yr, 1)) |
1190 |
> |
(long)sizeof(uby8)*2*picres.xr*picres.yr, SEEK_CUR)) |
1191 |
|
goto seekerr; |
1192 |
|
} |
1193 |
|
} |
1206 |
|
if (fin2 == NULL) |
1207 |
|
goto namerr; |
1208 |
|
if (fseek(fin2, |
1209 |
< |
(long)sizeof(uint16)*picres.xr*picres.yr, 1)) |
1209 |
> |
(long)sizeof(uint16)*picres.xr*picres.yr, SEEK_CUR)) |
1210 |
|
goto seekerr; |
1211 |
|
if (fseek(fin3, |
1212 |
< |
(long)sizeof(uint16)*2*picres.xr*picres.yr, 1)) |
1212 |
> |
(long)sizeof(uint16)*2*picres.xr*picres.yr, SEEK_CUR)) |
1213 |
|
goto seekerr; |
1214 |
|
} |
1215 |
|
} |
1216 |
|
return; |
1217 |
|
} |
1218 |
< |
badopt: |
1218 |
> |
/* badopt: */ /* label not used */ |
1219 |
|
fprintf(stderr, "%s: botched file type\n", progname); |
1220 |
|
quit(1); |
1221 |
|
namerr: |