1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* pvalue.c - program to print pixel values. |
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 |
|
|
16 |
|
#define min(a,b) ((a)<(b)?(a):(b)) |
17 |
|
|
19 |
|
#define ALL 3 |
20 |
|
#define BRIGHT 4 |
21 |
|
|
24 |
– |
#define brightonly (putprim==BRIGHT) |
25 |
– |
|
22 |
|
RESOLU picres; /* resolution of picture */ |
27 |
– |
|
23 |
|
int uniq = 0; /* print only unique values? */ |
29 |
– |
|
24 |
|
int doexposure = 0; /* exposure change? (>100 to print) */ |
31 |
– |
|
25 |
|
int dataonly = 0; /* data only format? */ |
33 |
– |
|
26 |
|
int putprim = ALL; /* what to put out */ |
35 |
– |
|
27 |
|
int reverse = 0; /* reverse conversion? */ |
37 |
– |
|
28 |
|
int format = 'a'; /* input/output format */ |
29 |
|
char *fmtid = "ascii"; /* format identifier for header */ |
40 |
– |
|
30 |
|
int header = 1; /* do header? */ |
42 |
– |
|
31 |
|
long skipbytes = 0; /* skip bytes in input? */ |
32 |
< |
|
32 |
> |
int swapbytes = 0; /* swap bytes? */ |
33 |
|
int interleave = 1; /* file is interleaved? */ |
46 |
– |
|
34 |
|
int resolution = 1; /* put/get resolution string? */ |
48 |
– |
|
35 |
|
int original = 0; /* convert to original values? */ |
50 |
– |
|
36 |
|
int wrongformat = 0; /* wrong input format? */ |
52 |
– |
|
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 |
|
|
65 |
– |
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; |
86 |
< |
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; |
91 |
< |
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; |
173 |
|
} |
174 |
|
break; |
175 |
|
case 'd': /* data only (no indices) */ |
176 |
< |
dataonly = argv[i][0] == '-'; |
176 |
> |
dataonly = (argv[i][0] == '-'); |
177 |
|
switch (argv[i][2]) { |
178 |
|
case '\0': |
179 |
|
case 'a': /* ascii */ |
189 |
|
format = 'b'; |
190 |
|
fmtid = "byte"; |
191 |
|
break; |
192 |
+ |
case 'W': /* 16-bit swapped */ |
193 |
+ |
swapbytes = 1; |
194 |
+ |
case 'w': /* 16-bit */ |
195 |
+ |
dataonly = 1; |
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) |
243 |
> |
if (dataonly && format == 'b') { |
244 |
> |
if (putprim == ALL) |
245 |
> |
fmtid = "24-bit_rgb"; |
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 = "24-bit_rgb"; |
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 |
261 |
< |
setmode(fileno(stdout), O_BINARY); |
262 |
< |
if (format != 'a' && format != 'i') |
263 |
< |
setmode(fileno(fin), O_BINARY); |
264 |
< |
#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); |
310 |
< |
if (format != 'a' && format != 'i') |
311 |
< |
setmode(fileno(stdout), O_BINARY); |
312 |
< |
#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", |
375 |
|
} |
376 |
|
if (header) { |
377 |
|
printargs(i, argv, stdout); |
378 |
+ |
printf("NCOMP=%d\n", putprim==ALL ? 3 : 1); |
379 |
+ |
if (!resolution && dataonly && !uniq) |
380 |
+ |
printf("NCOLS=%d\nNROWS=%d\n", scanlen(&picres), |
381 |
+ |
numscans(&picres)); |
382 |
|
if (expval < .99 || expval > 1.01) |
383 |
|
fputexpos(expval, stdout); |
384 |
+ |
if (swapbytes) { |
385 |
+ |
if (nativebigendian()) |
386 |
+ |
puts("BigEndian=0"); |
387 |
+ |
else |
388 |
+ |
puts("BigEndian=1"); |
389 |
+ |
} else if ((format != 'a') & (format != 'i') & |
390 |
+ |
(format != 'b')) |
391 |
+ |
fputendian(stdout); |
392 |
|
fputformat(fmtid, stdout); |
393 |
|
putchar('\n'); |
394 |
|
} |
398 |
|
} |
399 |
|
|
400 |
|
quit(0); |
401 |
+ |
return 0; /* pro forma return */ |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
< |
int |
406 |
< |
checkhead(line) /* deal with line from header */ |
407 |
< |
char *line; |
405 |
> |
static int |
406 |
> |
checkhead( /* deal with line from header */ |
407 |
> |
char *line, |
408 |
> |
void *p |
409 |
> |
) |
410 |
|
{ |
411 |
< |
char fmt[32]; |
411 |
> |
FILE *fout = (FILE *)p; |
412 |
> |
char fmt[MAXFMTLEN]; |
413 |
|
double d; |
414 |
|
COLOR ctmp; |
415 |
+ |
int rv; |
416 |
|
|
417 |
|
if (formatval(fmt, line)) { |
418 |
< |
if (!strcmp(fmt, CIEFMT)) { |
418 |
> |
if (reverse) |
419 |
> |
wrongformat = strcmp(fmt, fmtid); |
420 |
> |
else if (!strcmp(fmt, CIEFMT)) |
421 |
|
mybright = &xyz_bright; |
422 |
< |
if (original) { |
353 |
< |
scalecolor(exposure, 1./WHTEFFICACY); |
354 |
< |
doexposure++; |
355 |
< |
} |
356 |
< |
} else if (!strcmp(fmt, COLRFMT)) |
422 |
> |
else if (!strcmp(fmt, COLRFMT)) |
423 |
|
mybright = &rgb_bright; |
424 |
|
else |
425 |
|
wrongformat++; |
426 |
< |
} else if (original && isexpos(line)) { |
426 |
> |
return(1); |
427 |
> |
} |
428 |
> |
if (original && isexpos(line)) { |
429 |
|
d = 1.0/exposval(line); |
430 |
|
scalecolor(exposure, d); |
431 |
|
doexposure++; |
432 |
< |
} else if (original && iscolcor(line)) { |
432 |
> |
return(1); |
433 |
> |
} |
434 |
> |
if (original && iscolcor(line)) { |
435 |
|
colcorval(ctmp, line); |
436 |
|
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
437 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
438 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
439 |
|
doexposure++; |
440 |
< |
} else if (header) |
441 |
< |
fputs(line, stdout); |
440 |
> |
return(1); |
441 |
> |
} |
442 |
> |
if ((rv = isbigendian(line)) >= 0) { |
443 |
> |
if (reverse) |
444 |
> |
swapbytes = (nativebigendian() != rv); |
445 |
> |
return(1); |
446 |
> |
} |
447 |
> |
if (fout != NULL) |
448 |
> |
fputs(line, fout); |
449 |
|
return(0); |
450 |
|
} |
451 |
|
|
452 |
|
|
453 |
< |
pixtoval() /* convert picture to values */ |
453 |
> |
static void |
454 |
> |
pixtoval(void) /* convert picture to values */ |
455 |
|
{ |
456 |
< |
register COLOR *scanln; |
456 |
> |
COLOR *scanln; |
457 |
|
int dogamma; |
458 |
|
COLOR lastc; |
459 |
< |
FLOAT hv[2]; |
459 |
> |
RREAL hv[2]; |
460 |
|
int startprim, endprim; |
461 |
|
long startpos; |
462 |
< |
int y; |
385 |
< |
register int x; |
462 |
> |
int x, y; |
463 |
|
|
464 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
465 |
|
if (scanln == NULL) { |
467 |
|
quit(1); |
468 |
|
} |
469 |
|
dogamma = gamcor < .95 || gamcor > 1.05; |
470 |
< |
if (putprim == ALL && !interleave) { |
470 |
> |
if ((putprim == ALL) & !interleave) { |
471 |
|
startprim = RED; endprim = BLU; |
472 |
|
startpos = ftell(fin); |
473 |
|
} else { |
474 |
|
startprim = putprim; endprim = putprim; |
475 |
|
} |
476 |
|
for (putprim = startprim; putprim <= endprim; putprim++) { |
477 |
< |
if (putprim != startprim && fseek(fin, startpos, 0)) { |
477 |
> |
if (putprim != startprim && fseek(fin, startpos, SEEK_SET)) { |
478 |
|
fprintf(stderr, "%s: seek error on input file\n", |
479 |
|
progname); |
480 |
|
quit(1); |
487 |
|
quit(1); |
488 |
|
} |
489 |
|
for (x = 0; x < scanlen(&picres); x++) { |
490 |
< |
if (uniq) |
490 |
> |
if (uniq) { |
491 |
|
if ( colval(scanln[x],RED) == |
492 |
|
colval(lastc,RED) && |
493 |
|
colval(scanln[x],GRN) == |
497 |
|
continue; |
498 |
|
else |
499 |
|
copycolor(lastc, scanln[x]); |
500 |
+ |
} |
501 |
|
if (doexposure) |
502 |
|
multcolor(scanln[x], exposure); |
503 |
|
if (dogamma) |
523 |
|
} |
524 |
|
|
525 |
|
|
526 |
< |
valtopix() /* convert values to a pixel file */ |
526 |
> |
static void |
527 |
> |
valtopix(void) /* convert values to a pixel file */ |
528 |
|
{ |
529 |
< |
int dogamma; |
530 |
< |
register COLOR *scanln; |
531 |
< |
int y; |
532 |
< |
register int x; |
529 |
> |
int dogamma; |
530 |
> |
COLOR *scanln; |
531 |
> |
COLR rgbe; |
532 |
> |
int x, y; |
533 |
|
|
534 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
535 |
|
if (scanln == NULL) { |
558 |
|
pow(colval(scanln[x],BLU), gamcor)); |
559 |
|
if (doexposure) |
560 |
|
multcolor(scanln[x], exposure); |
561 |
+ |
if (uniq) { /* uncompressed? */ |
562 |
+ |
setcolr(rgbe, scanln[x][RED], |
563 |
+ |
scanln[x][GRN], |
564 |
+ |
scanln[x][BLU]); |
565 |
+ |
if (putbinary(rgbe, sizeof(COLR), 1, stdout) != 1) |
566 |
+ |
goto writerr; |
567 |
+ |
} |
568 |
|
} |
569 |
< |
if (fwritescan(scanln, scanlen(&picres), stdout) < 0) { |
570 |
< |
fprintf(stderr, "%s: write error\n", progname); |
571 |
< |
quit(1); |
486 |
< |
} |
569 |
> |
/* write scan if compressed */ |
570 |
> |
if (!uniq && fwritescan(scanln, scanlen(&picres), stdout) < 0) |
571 |
> |
goto writerr; |
572 |
|
} |
573 |
|
free((void *)scanln); |
574 |
+ |
return; |
575 |
+ |
writerr: |
576 |
+ |
fprintf(stderr, "%s: write error\n", progname); |
577 |
+ |
quit(1); |
578 |
|
} |
579 |
|
|
580 |
|
|
586 |
|
} |
587 |
|
|
588 |
|
|
589 |
< |
getcascii(col) /* get an ascii color value from stream(s) */ |
590 |
< |
COLOR col; |
589 |
> |
static int |
590 |
> |
getcascii( /* get an ascii color value from stream(s) */ |
591 |
> |
COLOR col |
592 |
> |
) |
593 |
|
{ |
594 |
|
double vd[3]; |
595 |
|
|
607 |
|
} |
608 |
|
|
609 |
|
|
610 |
< |
getcdouble(col) /* get a double color value from stream(s) */ |
611 |
< |
COLOR col; |
610 |
> |
static int |
611 |
> |
getcdouble( /* get a double color value from stream(s) */ |
612 |
> |
COLOR col |
613 |
> |
) |
614 |
|
{ |
615 |
|
double vd[3]; |
616 |
|
|
617 |
|
if (fin2 == NULL) { |
618 |
< |
if (fread((char *)vd, sizeof(double), 3, fin) != 3) |
618 |
> |
if (getbinary(vd, sizeof(double), 3, fin) != 3) |
619 |
|
return(-1); |
620 |
|
} else { |
621 |
< |
if (fread((char *)vd, sizeof(double), 1, fin) != 1 || |
622 |
< |
fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 || |
623 |
< |
fread((char *)(vd+2), sizeof(double), 1, fin3) != 1) |
621 |
> |
if (getbinary(vd, sizeof(double), 1, fin) != 1 || |
622 |
> |
getbinary(vd+1, sizeof(double), 1, fin2) != 1 || |
623 |
> |
getbinary(vd+2, sizeof(double), 1, fin3) != 1) |
624 |
|
return(-1); |
625 |
|
} |
626 |
+ |
if (swapbytes) |
627 |
+ |
swap64((char *)vd, 3); |
628 |
|
setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]); |
629 |
|
return(0); |
630 |
|
} |
631 |
|
|
632 |
|
|
633 |
< |
getcfloat(col) /* get a float color value from stream(s) */ |
634 |
< |
COLOR col; |
633 |
> |
static int |
634 |
> |
getcfloat( /* get a float color value from stream(s) */ |
635 |
> |
COLOR col |
636 |
> |
) |
637 |
|
{ |
638 |
|
float vf[3]; |
639 |
|
|
640 |
|
if (fin2 == NULL) { |
641 |
< |
if (fread((char *)vf, sizeof(float), 3, fin) != 3) |
641 |
> |
if (getbinary(vf, sizeof(float), 3, fin) != 3) |
642 |
|
return(-1); |
643 |
|
} else { |
644 |
< |
if (fread((char *)vf, sizeof(float), 1, fin) != 1 || |
645 |
< |
fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 || |
646 |
< |
fread((char *)(vf+2), sizeof(float), 1, fin3) != 1) |
644 |
> |
if (getbinary(vf, sizeof(float), 1, fin) != 1 || |
645 |
> |
getbinary(vf+1, sizeof(float), 1, fin2) != 1 || |
646 |
> |
getbinary(vf+2, sizeof(float), 1, fin3) != 1) |
647 |
|
return(-1); |
648 |
|
} |
649 |
+ |
if (swapbytes) |
650 |
+ |
swap32((char *)vf, 3); |
651 |
|
setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]); |
652 |
|
return(0); |
653 |
|
} |
654 |
|
|
655 |
|
|
656 |
< |
getcint(col) /* get an int color value from stream(s) */ |
657 |
< |
COLOR col; |
656 |
> |
static int |
657 |
> |
getcint( /* get an int color value from stream(s) */ |
658 |
> |
COLOR col |
659 |
> |
) |
660 |
|
{ |
661 |
|
int vi[3]; |
662 |
|
|
675 |
|
} |
676 |
|
|
677 |
|
|
678 |
< |
getcbyte(col) /* get a byte color value from stream(s) */ |
679 |
< |
COLOR col; |
678 |
> |
static int |
679 |
> |
getcbyte( /* get a byte color value from stream(s) */ |
680 |
> |
COLOR col |
681 |
> |
) |
682 |
|
{ |
683 |
< |
BYTE vb[3]; |
683 |
> |
uby8 vb[3]; |
684 |
|
|
685 |
|
if (fin2 == NULL) { |
686 |
< |
if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3) |
686 |
> |
if (getbinary(vb, sizeof(uby8), 3, fin) != 3) |
687 |
|
return(-1); |
688 |
|
} else { |
689 |
< |
if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 || |
690 |
< |
fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 || |
691 |
< |
fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1) |
689 |
> |
if (getbinary(vb, sizeof(uby8), 1, fin) != 1 || |
690 |
> |
getbinary(vb+1, sizeof(uby8), 1, fin2) != 1 || |
691 |
> |
getbinary(vb+2, sizeof(uby8), 1, fin3) != 1) |
692 |
|
return(-1); |
693 |
|
} |
694 |
|
setcolor(col, (vb[rord[RED]]+.5)/256., |
697 |
|
} |
698 |
|
|
699 |
|
|
700 |
< |
getbascii(col) /* get an ascii brightness value from fin */ |
701 |
< |
COLOR col; |
700 |
> |
static int |
701 |
> |
getcword( /* get a 16-bit color value from stream(s) */ |
702 |
> |
COLOR col |
703 |
> |
) |
704 |
|
{ |
705 |
+ |
uint16 vw[3]; |
706 |
+ |
|
707 |
+ |
if (fin2 == NULL) { |
708 |
+ |
if (getbinary(vw, sizeof(uint16), 3, fin) != 3) |
709 |
+ |
return(-1); |
710 |
+ |
} else { |
711 |
+ |
if (getbinary(vw, sizeof(uint16), 1, fin) != 1 || |
712 |
+ |
getbinary(vw+1, sizeof(uint16), 1, fin2) != 1 || |
713 |
+ |
getbinary(vw+2, sizeof(uint16), 1, fin3) != 1) |
714 |
+ |
return(-1); |
715 |
+ |
} |
716 |
+ |
if (swapbytes) |
717 |
+ |
swap16((char *)vw, 3); |
718 |
+ |
setcolor(col, (vw[rord[RED]]+.5)/65536., |
719 |
+ |
(vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.); |
720 |
+ |
return(0); |
721 |
+ |
} |
722 |
+ |
|
723 |
+ |
|
724 |
+ |
static int |
725 |
+ |
getbascii( /* get an ascii brightness value from fin */ |
726 |
+ |
COLOR col |
727 |
+ |
) |
728 |
+ |
{ |
729 |
|
double vd; |
730 |
|
|
731 |
|
if (fscanf(fin, "%lf", &vd) != 1) |
735 |
|
} |
736 |
|
|
737 |
|
|
738 |
< |
getbdouble(col) /* get a double brightness value from fin */ |
739 |
< |
COLOR col; |
738 |
> |
static int |
739 |
> |
getbdouble( /* get a double brightness value from fin */ |
740 |
> |
COLOR col |
741 |
> |
) |
742 |
|
{ |
743 |
|
double vd; |
744 |
|
|
745 |
< |
if (fread((char *)&vd, sizeof(double), 1, fin) != 1) |
745 |
> |
if (getbinary(&vd, sizeof(double), 1, fin) != 1) |
746 |
|
return(-1); |
747 |
+ |
if (swapbytes) |
748 |
+ |
swap64((char *)&vd, 1); |
749 |
|
setcolor(col, vd, vd, vd); |
750 |
|
return(0); |
751 |
|
} |
752 |
|
|
753 |
|
|
754 |
< |
getbfloat(col) /* get a float brightness value from fin */ |
755 |
< |
COLOR col; |
754 |
> |
static int |
755 |
> |
getbfloat( /* get a float brightness value from fin */ |
756 |
> |
COLOR col |
757 |
> |
) |
758 |
|
{ |
759 |
|
float vf; |
760 |
|
|
761 |
< |
if (fread((char *)&vf, sizeof(float), 1, fin) != 1) |
761 |
> |
if (getbinary(&vf, sizeof(float), 1, fin) != 1) |
762 |
|
return(-1); |
763 |
+ |
if (swapbytes) |
764 |
+ |
swap32((char *)&vf, 1); |
765 |
|
setcolor(col, vf, vf, vf); |
766 |
|
return(0); |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
< |
getbint(col) /* get an int brightness value from fin */ |
771 |
< |
COLOR col; |
770 |
> |
static int |
771 |
> |
getbint( /* get an int brightness value from fin */ |
772 |
> |
COLOR col |
773 |
> |
) |
774 |
|
{ |
775 |
|
int vi; |
776 |
|
double d; |
783 |
|
} |
784 |
|
|
785 |
|
|
786 |
< |
getbbyte(col) /* get a byte brightness value from fin */ |
787 |
< |
COLOR col; |
786 |
> |
static int |
787 |
> |
getbbyte( /* get a byte brightness value from fin */ |
788 |
> |
COLOR col |
789 |
> |
) |
790 |
|
{ |
791 |
< |
BYTE vb; |
791 |
> |
uby8 vb; |
792 |
|
double d; |
793 |
|
|
794 |
< |
if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1) |
794 |
> |
if (getbinary(&vb, sizeof(uby8), 1, fin) != 1) |
795 |
|
return(-1); |
796 |
|
d = (vb+.5)/256.; |
797 |
|
setcolor(col, d, d, d); |
799 |
|
} |
800 |
|
|
801 |
|
|
802 |
< |
putcascii(col) /* put an ascii color to stdout */ |
803 |
< |
COLOR col; |
802 |
> |
static int |
803 |
> |
getbword( /* get a 16-bit brightness value from fin */ |
804 |
> |
COLOR col |
805 |
> |
) |
806 |
|
{ |
807 |
+ |
uint16 vw; |
808 |
+ |
double d; |
809 |
+ |
|
810 |
+ |
if (getbinary(&vw, sizeof(uint16), 1, fin) != 1) |
811 |
+ |
return(-1); |
812 |
+ |
if (swapbytes) |
813 |
+ |
swap16((char *)&vw, 1); |
814 |
+ |
d = (vw+.5)/65536.; |
815 |
+ |
setcolor(col, d, d, d); |
816 |
+ |
return(0); |
817 |
+ |
} |
818 |
+ |
|
819 |
+ |
|
820 |
+ |
static int |
821 |
+ |
putcascii( /* put an ascii color to stdout */ |
822 |
+ |
COLOR col |
823 |
+ |
) |
824 |
+ |
{ |
825 |
|
fprintf(stdout, "%15.3e %15.3e %15.3e\n", |
826 |
|
colval(col,ord[0]), |
827 |
|
colval(col,ord[1]), |
831 |
|
} |
832 |
|
|
833 |
|
|
834 |
< |
putcfloat(col) /* put a float color to stdout */ |
835 |
< |
COLOR col; |
834 |
> |
static int |
835 |
> |
putcfloat( /* put a float color to stdout */ |
836 |
> |
COLOR col |
837 |
> |
) |
838 |
|
{ |
839 |
|
float vf[3]; |
840 |
|
|
841 |
|
vf[0] = colval(col,ord[0]); |
842 |
|
vf[1] = colval(col,ord[1]); |
843 |
|
vf[2] = colval(col,ord[2]); |
844 |
< |
fwrite((char *)vf, sizeof(float), 3, stdout); |
844 |
> |
if (swapbytes) |
845 |
> |
swap32((char *)vf, 3); |
846 |
> |
putbinary(vf, sizeof(float), 3, stdout); |
847 |
|
|
848 |
|
return(ferror(stdout) ? -1 : 0); |
849 |
|
} |
850 |
|
|
851 |
|
|
852 |
< |
putcdouble(col) /* put a double color to stdout */ |
853 |
< |
COLOR col; |
852 |
> |
static int |
853 |
> |
putcdouble( /* put a double color to stdout */ |
854 |
> |
COLOR col |
855 |
> |
) |
856 |
|
{ |
857 |
|
double vd[3]; |
858 |
|
|
859 |
|
vd[0] = colval(col,ord[0]); |
860 |
|
vd[1] = colval(col,ord[1]); |
861 |
|
vd[2] = colval(col,ord[2]); |
862 |
< |
fwrite((char *)vd, sizeof(double), 3, stdout); |
862 |
> |
if (swapbytes) |
863 |
> |
swap64((char *)vd, 3); |
864 |
> |
putbinary(vd, sizeof(double), 3, stdout); |
865 |
|
|
866 |
|
return(ferror(stdout) ? -1 : 0); |
867 |
|
} |
868 |
|
|
869 |
|
|
870 |
< |
putcint(col) /* put an int color to stdout */ |
871 |
< |
COLOR col; |
870 |
> |
static int |
871 |
> |
putcint( /* put an int color to stdout */ |
872 |
> |
COLOR col |
873 |
> |
) |
874 |
|
{ |
875 |
|
fprintf(stdout, "%d %d %d\n", |
876 |
|
(int)(colval(col,ord[0])*256.), |
881 |
|
} |
882 |
|
|
883 |
|
|
884 |
< |
putcbyte(col) /* put a byte color to stdout */ |
885 |
< |
COLOR col; |
884 |
> |
static int |
885 |
> |
putcbyte( /* put a byte color to stdout */ |
886 |
> |
COLOR col |
887 |
> |
) |
888 |
|
{ |
889 |
< |
register int i; |
890 |
< |
BYTE vb[3]; |
889 |
> |
long i; |
890 |
> |
uby8 vb[3]; |
891 |
|
|
892 |
|
i = colval(col,ord[0])*256.; |
893 |
|
vb[0] = min(i,255); |
895 |
|
vb[1] = min(i,255); |
896 |
|
i = colval(col,ord[2])*256.; |
897 |
|
vb[2] = min(i,255); |
898 |
< |
fwrite((char *)vb, sizeof(BYTE), 3, stdout); |
898 |
> |
putbinary(vb, sizeof(uby8), 3, stdout); |
899 |
|
|
900 |
|
return(ferror(stdout) ? -1 : 0); |
901 |
|
} |
902 |
|
|
903 |
|
|
904 |
< |
putbascii(col) /* put an ascii brightness to stdout */ |
905 |
< |
COLOR col; |
904 |
> |
static int |
905 |
> |
putcword( /* put a 16-bit color to stdout */ |
906 |
> |
COLOR col |
907 |
> |
) |
908 |
|
{ |
909 |
+ |
long i; |
910 |
+ |
uint16 vw[3]; |
911 |
+ |
|
912 |
+ |
i = colval(col,ord[0])*65536.; |
913 |
+ |
vw[0] = min(i,65535); |
914 |
+ |
i = colval(col,ord[1])*65536.; |
915 |
+ |
vw[1] = min(i,65535); |
916 |
+ |
i = colval(col,ord[2])*65536.; |
917 |
+ |
vw[2] = min(i,65535); |
918 |
+ |
if (swapbytes) |
919 |
+ |
swap16((char *)vw, 3); |
920 |
+ |
putbinary(vw, sizeof(uint16), 3, stdout); |
921 |
+ |
|
922 |
+ |
return(ferror(stdout) ? -1 : 0); |
923 |
+ |
} |
924 |
+ |
|
925 |
+ |
|
926 |
+ |
static int |
927 |
+ |
putbascii( /* put an ascii brightness to stdout */ |
928 |
+ |
COLOR col |
929 |
+ |
) |
930 |
+ |
{ |
931 |
|
fprintf(stdout, "%15.3e\n", (*mybright)(col)); |
932 |
|
|
933 |
|
return(ferror(stdout) ? -1 : 0); |
934 |
|
} |
935 |
|
|
936 |
|
|
937 |
< |
putbfloat(col) /* put a float brightness to stdout */ |
938 |
< |
COLOR col; |
937 |
> |
static int |
938 |
> |
putbfloat( /* put a float brightness to stdout */ |
939 |
> |
COLOR col |
940 |
> |
) |
941 |
|
{ |
942 |
|
float vf; |
943 |
|
|
944 |
|
vf = (*mybright)(col); |
945 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
945 |
> |
if (swapbytes) |
946 |
> |
swap32((char *)&vf, 1); |
947 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
948 |
|
|
949 |
|
return(ferror(stdout) ? -1 : 0); |
950 |
|
} |
951 |
|
|
952 |
|
|
953 |
< |
putbdouble(col) /* put a double brightness to stdout */ |
954 |
< |
COLOR col; |
953 |
> |
static int |
954 |
> |
putbdouble( /* put a double brightness to stdout */ |
955 |
> |
COLOR col |
956 |
> |
) |
957 |
|
{ |
958 |
|
double vd; |
959 |
|
|
960 |
|
vd = (*mybright)(col); |
961 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
961 |
> |
if (swapbytes) |
962 |
> |
swap64((char *)&vd, 1); |
963 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
964 |
|
|
965 |
|
return(ferror(stdout) ? -1 : 0); |
966 |
|
} |
967 |
|
|
968 |
|
|
969 |
< |
putbint(col) /* put an int brightness to stdout */ |
970 |
< |
COLOR col; |
969 |
> |
static int |
970 |
> |
putbint( /* put an int brightness to stdout */ |
971 |
> |
COLOR col |
972 |
> |
) |
973 |
|
{ |
974 |
|
fprintf(stdout, "%d\n", (int)((*mybright)(col)*256.)); |
975 |
|
|
977 |
|
} |
978 |
|
|
979 |
|
|
980 |
< |
putbbyte(col) /* put a byte brightness to stdout */ |
981 |
< |
COLOR col; |
980 |
> |
static int |
981 |
> |
putbbyte( /* put a byte brightness to stdout */ |
982 |
> |
COLOR col |
983 |
> |
) |
984 |
|
{ |
985 |
< |
register int i; |
986 |
< |
BYTE vb; |
985 |
> |
int i; |
986 |
> |
uby8 vb; |
987 |
|
|
988 |
|
i = (*mybright)(col)*256.; |
989 |
|
vb = min(i,255); |
990 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
990 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
991 |
|
|
992 |
|
return(ferror(stdout) ? -1 : 0); |
993 |
|
} |
994 |
|
|
995 |
|
|
996 |
< |
putpascii(col) /* put an ascii primary to stdout */ |
997 |
< |
COLOR col; |
996 |
> |
static int |
997 |
> |
putbword( /* put a 16-bit brightness to stdout */ |
998 |
> |
COLOR col |
999 |
> |
) |
1000 |
|
{ |
1001 |
+ |
long i; |
1002 |
+ |
uint16 vw; |
1003 |
+ |
|
1004 |
+ |
i = (*mybright)(col)*65536.; |
1005 |
+ |
vw = min(i,65535); |
1006 |
+ |
if (swapbytes) |
1007 |
+ |
swap16((char *)&vw, 1); |
1008 |
+ |
putbinary(&vw, sizeof(uint16), 1, stdout); |
1009 |
+ |
|
1010 |
+ |
return(ferror(stdout) ? -1 : 0); |
1011 |
+ |
} |
1012 |
+ |
|
1013 |
+ |
|
1014 |
+ |
static int |
1015 |
+ |
putpascii( /* put an ascii primary to stdout */ |
1016 |
+ |
COLOR col |
1017 |
+ |
) |
1018 |
+ |
{ |
1019 |
|
fprintf(stdout, "%15.3e\n", colval(col,putprim)); |
1020 |
|
|
1021 |
|
return(ferror(stdout) ? -1 : 0); |
1022 |
|
} |
1023 |
|
|
1024 |
|
|
1025 |
< |
putpfloat(col) /* put a float primary to stdout */ |
1026 |
< |
COLOR col; |
1025 |
> |
static int |
1026 |
> |
putpfloat( /* put a float primary to stdout */ |
1027 |
> |
COLOR col |
1028 |
> |
) |
1029 |
|
{ |
1030 |
|
float vf; |
1031 |
|
|
1032 |
|
vf = colval(col,putprim); |
1033 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
1033 |
> |
if (swapbytes) |
1034 |
> |
swap32((char *)&vf, 1); |
1035 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
1036 |
|
|
1037 |
|
return(ferror(stdout) ? -1 : 0); |
1038 |
|
} |
1039 |
|
|
1040 |
|
|
1041 |
< |
putpdouble(col) /* put a double primary to stdout */ |
1042 |
< |
COLOR col; |
1041 |
> |
static int |
1042 |
> |
putpdouble( /* put a double primary to stdout */ |
1043 |
> |
COLOR col |
1044 |
> |
) |
1045 |
|
{ |
1046 |
|
double vd; |
1047 |
|
|
1048 |
|
vd = colval(col,putprim); |
1049 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
1049 |
> |
if (swapbytes) |
1050 |
> |
swap64((char *)&vd, 1); |
1051 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
1052 |
|
|
1053 |
|
return(ferror(stdout) ? -1 : 0); |
1054 |
|
} |
1055 |
|
|
1056 |
|
|
1057 |
< |
putpint(col) /* put an int primary to stdout */ |
1058 |
< |
COLOR col; |
1057 |
> |
static int |
1058 |
> |
putpint( /* put an int primary to stdout */ |
1059 |
> |
COLOR col |
1060 |
> |
) |
1061 |
|
{ |
1062 |
|
fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.)); |
1063 |
|
|
1065 |
|
} |
1066 |
|
|
1067 |
|
|
1068 |
< |
putpbyte(col) /* put a byte primary to stdout */ |
1069 |
< |
COLOR col; |
1068 |
> |
static int |
1069 |
> |
putpbyte( /* put a byte primary to stdout */ |
1070 |
> |
COLOR col |
1071 |
> |
) |
1072 |
|
{ |
1073 |
< |
register int i; |
1074 |
< |
BYTE vb; |
1073 |
> |
long i; |
1074 |
> |
uby8 vb; |
1075 |
|
|
1076 |
|
i = colval(col,putprim)*256.; |
1077 |
|
vb = min(i,255); |
1078 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
1078 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
1079 |
|
|
1080 |
|
return(ferror(stdout) ? -1 : 0); |
1081 |
|
} |
1082 |
|
|
1083 |
|
|
1084 |
< |
set_io() /* set put and get functions */ |
1084 |
> |
static int |
1085 |
> |
putpword( /* put a 16-bit primary to stdout */ |
1086 |
> |
COLOR col |
1087 |
> |
) |
1088 |
|
{ |
1089 |
+ |
long i; |
1090 |
+ |
uint16 vw; |
1091 |
+ |
|
1092 |
+ |
i = colval(col,putprim)*65536.; |
1093 |
+ |
vw = min(i,65535); |
1094 |
+ |
if (swapbytes) |
1095 |
+ |
swap16((char *)&vw, 1); |
1096 |
+ |
putbinary(&vw, sizeof(uint16), 1, stdout); |
1097 |
+ |
|
1098 |
+ |
return(ferror(stdout) ? -1 : 0); |
1099 |
+ |
} |
1100 |
+ |
|
1101 |
+ |
|
1102 |
+ |
static void |
1103 |
+ |
set_io(void) /* set put and get functions */ |
1104 |
+ |
{ |
1105 |
|
switch (format) { |
1106 |
|
case 'a': /* ascii */ |
1107 |
|
if (putprim == BRIGHT) { |
1135 |
|
if (fin2 == NULL) |
1136 |
|
goto namerr; |
1137 |
|
if (fseek(fin2, |
1138 |
< |
(long)sizeof(float)*picres.xr*picres.yr, 1)) |
1138 |
> |
(long)sizeof(float)*picres.xr*picres.yr, SEEK_CUR)) |
1139 |
|
goto seekerr; |
1140 |
|
if (fseek(fin3, |
1141 |
< |
(long)sizeof(float)*2*picres.xr*picres.yr, 1)) |
1141 |
> |
(long)sizeof(float)*2*picres.xr*picres.yr, SEEK_CUR)) |
1142 |
|
goto seekerr; |
1143 |
|
} |
1144 |
|
} |
1157 |
|
if (fin2 == NULL) |
1158 |
|
goto namerr; |
1159 |
|
if (fseek(fin2, |
1160 |
< |
(long)sizeof(double)*picres.xr*picres.yr, 1)) |
1160 |
> |
(long)sizeof(double)*picres.xr*picres.yr, SEEK_CUR)) |
1161 |
|
goto seekerr; |
1162 |
|
if (fseek(fin3, |
1163 |
< |
(long)sizeof(double)*2*picres.xr*picres.yr, 1)) |
1163 |
> |
(long)sizeof(double)*2*picres.xr*picres.yr, SEEK_CUR)) |
1164 |
|
goto seekerr; |
1165 |
|
} |
1166 |
|
} |
1197 |
|
if (fin2 == NULL) |
1198 |
|
goto namerr; |
1199 |
|
if (fseek(fin2, |
1200 |
< |
(long)sizeof(BYTE)*picres.xr*picres.yr, 1)) |
1200 |
> |
(long)sizeof(uby8)*picres.xr*picres.yr, SEEK_CUR)) |
1201 |
|
goto seekerr; |
1202 |
|
if (fseek(fin3, |
1203 |
< |
(long)sizeof(BYTE)*2*picres.xr*picres.yr, 1)) |
1203 |
> |
(long)sizeof(uby8)*2*picres.xr*picres.yr, SEEK_CUR)) |
1204 |
|
goto seekerr; |
1205 |
|
} |
1206 |
|
} |
1207 |
|
return; |
1208 |
+ |
case 'w': /* 16-bit */ |
1209 |
+ |
if (putprim == BRIGHT) { |
1210 |
+ |
getval = getbword; |
1211 |
+ |
putval = putbword; |
1212 |
+ |
} else if (putprim != ALL) { |
1213 |
+ |
getval = getbword; |
1214 |
+ |
putval = putpword; |
1215 |
+ |
} else { |
1216 |
+ |
getval = getcword; |
1217 |
+ |
putval = putcword; |
1218 |
+ |
if (reverse && !interleave) { |
1219 |
+ |
if (fin2 == NULL) |
1220 |
+ |
goto namerr; |
1221 |
+ |
if (fseek(fin2, |
1222 |
+ |
(long)sizeof(uint16)*picres.xr*picres.yr, SEEK_CUR)) |
1223 |
+ |
goto seekerr; |
1224 |
+ |
if (fseek(fin3, |
1225 |
+ |
(long)sizeof(uint16)*2*picres.xr*picres.yr, SEEK_CUR)) |
1226 |
+ |
goto seekerr; |
1227 |
+ |
} |
1228 |
+ |
} |
1229 |
+ |
return; |
1230 |
|
} |
1231 |
< |
badopt: |
1231 |
> |
/* badopt: */ /* label not used */ |
1232 |
|
fprintf(stderr, "%s: botched file type\n", progname); |
1233 |
|
quit(1); |
1234 |
|
namerr: |