36 |
|
int wrongformat = 0; /* wrong input format? */ |
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 |
|
|
93 |
|
char **argv |
94 |
|
) |
95 |
|
{ |
96 |
< |
double d, expval = 1.0; |
97 |
< |
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 */ |
118 |
|
case 'o': /* original values */ |
119 |
|
original = argv[i][0] == '-'; |
120 |
|
break; |
121 |
+ |
case 'O': /* original watts/sr/m^2 */ |
122 |
+ |
original = -(argv[i][0] == '-'); |
123 |
+ |
break; |
124 |
|
case 'g': /* gamma correction */ |
125 |
|
gamcor = atof(argv[i+1]); |
126 |
|
if (argv[i][0] == '+') |
153 |
|
case 'b': /* brightness values */ |
154 |
|
putprim = argv[i][0] == '-' ? BRIGHT : ALL; |
155 |
|
break; |
156 |
< |
case 'p': /* put primary */ |
156 |
> |
case 'p': /* primary controls */ |
157 |
|
switch (argv[i][2]) { |
158 |
+ |
/* these two options affect -r conversion */ |
159 |
+ |
case '\0': |
160 |
+ |
myprims[RED][CIEX] = atof(argv[++i]); |
161 |
+ |
myprims[RED][CIEY] = atof(argv[++i]); |
162 |
+ |
myprims[GRN][CIEX] = atof(argv[++i]); |
163 |
+ |
myprims[GRN][CIEY] = atof(argv[++i]); |
164 |
+ |
myprims[BLU][CIEX] = atof(argv[++i]); |
165 |
+ |
myprims[BLU][CIEY] = atof(argv[++i]); |
166 |
+ |
myprims[WHT][CIEX] = atof(argv[++i]); |
167 |
+ |
myprims[WHT][CIEY] = atof(argv[++i]); |
168 |
+ |
outprims = myprims; |
169 |
+ |
break; |
170 |
+ |
case 'x': case 'X': outprims = NULL; break; |
171 |
+ |
/* the following options affect +r only */ |
172 |
|
case 'r': case 'R': putprim = RED; break; |
173 |
|
case 'g': case 'G': putprim = GRN; break; |
174 |
|
case 'b': case 'B': putprim = BLU; break; |
176 |
|
} |
177 |
|
break; |
178 |
|
case 'd': /* data only (no indices) */ |
179 |
< |
dataonly = argv[i][0] == '-'; |
179 |
> |
dataonly = (argv[i][0] == '-'); |
180 |
|
switch (argv[i][2]) { |
181 |
|
case '\0': |
182 |
|
case 'a': /* ascii */ |
255 |
|
else |
256 |
|
fmtid = "16-bit_grey"; |
257 |
|
} |
258 |
+ |
if (!reverse || (format != 'a') & (format != 'i')) |
259 |
+ |
inpmode = "rb"; |
260 |
|
/* assign reverse ordering */ |
261 |
|
rord[ord[0]] = 0; |
262 |
|
rord[ord[1]] = 1; |
263 |
|
rord[ord[2]] = 2; |
264 |
|
/* get input */ |
265 |
|
if (i == argc) { |
266 |
+ |
long n = skipbytes; |
267 |
+ |
if (inpmode[1] == 'b') |
268 |
+ |
SET_FILE_BINARY(stdin); |
269 |
+ |
while (n-- > 0) |
270 |
+ |
if (getchar() == EOF) { |
271 |
+ |
fprintf(stderr, |
272 |
+ |
"%s: cannot skip %ld bytes on standard input\n", |
273 |
+ |
progname, skipbytes); |
274 |
+ |
quit(1); |
275 |
+ |
} |
276 |
|
fin = stdin; |
277 |
|
} else if (i < argc) { |
278 |
< |
if ((fin = fopen(argv[i], "r")) == NULL) { |
278 |
> |
if ((fin = fopen(argv[i], inpmode)) == NULL) { |
279 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
280 |
|
progname, argv[i]); |
281 |
|
quit(1); |
282 |
|
} |
283 |
|
if (reverse && putprim != BRIGHT && i == argc-3) { |
284 |
< |
if ((fin2 = fopen(argv[i+1], "r")) == NULL) { |
284 |
> |
if ((fin2 = fopen(argv[i+1], inpmode)) == NULL) { |
285 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
286 |
|
progname, argv[i+1]); |
287 |
|
quit(1); |
288 |
|
} |
289 |
< |
if ((fin3 = fopen(argv[i+2], "r")) == NULL) { |
289 |
> |
if ((fin3 = fopen(argv[i+2], inpmode)) == NULL) { |
290 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
291 |
|
progname, argv[i+2]); |
292 |
|
quit(1); |
295 |
|
} else if (i != argc-1) |
296 |
|
fin = NULL; |
297 |
|
if (reverse && putprim != BRIGHT && !interleave) { |
298 |
< |
fin2 = fopen(argv[i], "r"); |
299 |
< |
fin3 = fopen(argv[i], "r"); |
298 |
> |
fin2 = fopen(argv[i], inpmode); |
299 |
> |
fin3 = fopen(argv[i], inpmode); |
300 |
|
} |
301 |
< |
if (skipbytes && (fseek(fin, skipbytes, 0) || (fin2 != NULL && |
302 |
< |
(fseek(fin2, skipbytes, 0) || |
303 |
< |
fseek(fin3, skipbytes, 0))))) { |
301 |
> |
if (skipbytes && (fseek(fin, skipbytes, SEEK_SET) || (fin2 != NULL && |
302 |
> |
fseek(fin2, skipbytes, SEEK_SET) | |
303 |
> |
fseek(fin3, skipbytes, SEEK_SET)))) { |
304 |
|
fprintf(stderr, "%s: cannot skip %ld bytes on input\n", |
305 |
|
progname, skipbytes); |
306 |
|
quit(1); |
312 |
|
} |
313 |
|
|
314 |
|
if (reverse) { |
282 |
– |
#ifdef _WIN32 |
315 |
|
SET_FILE_BINARY(stdout); |
284 |
– |
if (format != 'a' && format != 'i') |
285 |
– |
SET_FILE_BINARY(fin); |
286 |
– |
#endif |
316 |
|
/* get header */ |
317 |
|
if (header) { |
318 |
< |
if (checkheader(fin, fmtid, stdout) < 0) { |
319 |
< |
fprintf(stderr, "%s: wrong input format\n", |
320 |
< |
progname); |
318 |
> |
getheader(fin, checkhead, stdout); |
319 |
> |
if (wrongformat) { |
320 |
> |
fprintf(stderr, "%s: wrong input format (expected %s)\n", |
321 |
> |
progname, fmtid); |
322 |
|
quit(1); |
323 |
|
} |
324 |
|
if (fin2 != NULL) { |
352 |
|
printargs(i, argv, stdout); |
353 |
|
if (expval < .99 || expval > 1.01) |
354 |
|
fputexpos(expval, stdout); |
355 |
< |
fputformat(COLRFMT, stdout); |
355 |
> |
if (outprims != NULL) { |
356 |
> |
if (outprims != stdprims) |
357 |
> |
fputprims(outprims, stdout); |
358 |
> |
fputformat(COLRFMT, stdout); |
359 |
> |
} else { /* XYZ data */ |
360 |
> |
if (original < 0) { |
361 |
> |
scalecolor(exposure, WHTEFFICACY); |
362 |
> |
doexposure++; |
363 |
> |
} |
364 |
> |
fputformat(CIEFMT, stdout); |
365 |
> |
} |
366 |
|
putchar('\n'); |
367 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
368 |
|
valtopix(); |
369 |
|
} else { |
370 |
< |
#ifdef _WIN32 |
331 |
< |
SET_FILE_BINARY(fin); |
332 |
< |
if (format != 'a' && format != 'i') |
370 |
> |
if ((format != 'a') & (format != 'i')) |
371 |
|
SET_FILE_BINARY(stdout); |
334 |
– |
#endif |
372 |
|
/* get header */ |
373 |
< |
getheader(fin, checkhead, NULL); |
373 |
> |
getheader(fin, checkhead, header ? stdout : (FILE *)NULL); |
374 |
|
if (wrongformat) { |
375 |
|
fprintf(stderr, |
376 |
|
"%s: input not a Radiance RGBE picture\n", |
381 |
|
fprintf(stderr, "%s: missing resolution\n", progname); |
382 |
|
quit(1); |
383 |
|
} |
384 |
+ |
if (original < 0 && mybright == &xyz_bright) { |
385 |
+ |
scalecolor(exposure, 1./WHTEFFICACY); |
386 |
+ |
doexposure++; |
387 |
+ |
} |
388 |
|
if (header) { |
389 |
|
printargs(i, argv, stdout); |
390 |
+ |
printf("NCOMP=%d\n", putprim==ALL ? 3 : 1); |
391 |
+ |
if (!resolution && dataonly && !uniq) |
392 |
+ |
printf("NCOLS=%d\nNROWS=%d\n", scanlen(&picres), |
393 |
+ |
numscans(&picres)); |
394 |
|
if (expval < .99 || expval > 1.01) |
395 |
|
fputexpos(expval, stdout); |
396 |
+ |
if (swapbytes) { |
397 |
+ |
if (nativebigendian()) |
398 |
+ |
puts("BigEndian=0"); |
399 |
+ |
else |
400 |
+ |
puts("BigEndian=1"); |
401 |
+ |
} else if ((format != 'a') & (format != 'i') & |
402 |
+ |
(format != 'b')) |
403 |
+ |
fputendian(stdout); |
404 |
|
fputformat(fmtid, stdout); |
405 |
|
putchar('\n'); |
406 |
|
} |
420 |
|
void *p |
421 |
|
) |
422 |
|
{ |
423 |
< |
char fmt[32]; |
423 |
> |
FILE *fout = (FILE *)p; |
424 |
> |
char fmt[MAXFMTLEN]; |
425 |
|
double d; |
426 |
|
COLOR ctmp; |
427 |
+ |
int rv; |
428 |
|
|
429 |
|
if (formatval(fmt, line)) { |
430 |
< |
if (!strcmp(fmt, CIEFMT)) |
430 |
> |
if (reverse) |
431 |
> |
wrongformat = strcmp(fmt, fmtid); |
432 |
> |
else if (!strcmp(fmt, CIEFMT)) |
433 |
|
mybright = &xyz_bright; |
434 |
|
else if (!strcmp(fmt, COLRFMT)) |
435 |
|
mybright = &rgb_bright; |
436 |
|
else |
437 |
|
wrongformat++; |
438 |
< |
} else if (original && isexpos(line)) { |
438 |
> |
return(1); |
439 |
> |
} |
440 |
> |
if (original && isexpos(line)) { |
441 |
|
d = 1.0/exposval(line); |
442 |
|
scalecolor(exposure, d); |
443 |
|
doexposure++; |
444 |
< |
} else if (original && iscolcor(line)) { |
444 |
> |
return(1); |
445 |
> |
} |
446 |
> |
if (original && iscolcor(line)) { |
447 |
|
colcorval(ctmp, line); |
448 |
|
setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED), |
449 |
|
colval(exposure,GRN)/colval(ctmp,GRN), |
450 |
|
colval(exposure,BLU)/colval(ctmp,BLU)); |
451 |
|
doexposure++; |
452 |
< |
} else if (header) |
453 |
< |
fputs(line, stdout); |
452 |
> |
return(1); |
453 |
> |
} |
454 |
> |
if ((rv = isbigendian(line)) >= 0) { |
455 |
> |
if (reverse) |
456 |
> |
swapbytes = (nativebigendian() != rv); |
457 |
> |
return(1); |
458 |
> |
} |
459 |
> |
if (fout != NULL) |
460 |
> |
fputs(line, fout); |
461 |
|
return(0); |
462 |
|
} |
463 |
|
|
465 |
|
static void |
466 |
|
pixtoval(void) /* convert picture to values */ |
467 |
|
{ |
468 |
< |
register COLOR *scanln; |
468 |
> |
COLOR *scanln; |
469 |
|
int dogamma; |
470 |
|
COLOR lastc; |
471 |
|
RREAL hv[2]; |
472 |
|
int startprim, endprim; |
473 |
|
long startpos; |
474 |
< |
int y; |
407 |
< |
register int x; |
474 |
> |
int x, y; |
475 |
|
|
476 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
477 |
|
if (scanln == NULL) { |
479 |
|
quit(1); |
480 |
|
} |
481 |
|
dogamma = gamcor < .95 || gamcor > 1.05; |
482 |
< |
if (putprim == ALL && !interleave) { |
482 |
> |
if ((putprim == ALL) & !interleave) { |
483 |
|
startprim = RED; endprim = BLU; |
484 |
|
startpos = ftell(fin); |
485 |
|
} else { |
486 |
|
startprim = putprim; endprim = putprim; |
487 |
|
} |
488 |
|
for (putprim = startprim; putprim <= endprim; putprim++) { |
489 |
< |
if (putprim != startprim && fseek(fin, startpos, 0)) { |
489 |
> |
if (putprim != startprim && fseek(fin, startpos, SEEK_SET)) { |
490 |
|
fprintf(stderr, "%s: seek error on input file\n", |
491 |
|
progname); |
492 |
|
quit(1); |
538 |
|
static void |
539 |
|
valtopix(void) /* convert values to a pixel file */ |
540 |
|
{ |
541 |
< |
int dogamma; |
542 |
< |
register COLOR *scanln; |
543 |
< |
int y; |
544 |
< |
register int x; |
541 |
> |
int dogamma; |
542 |
> |
COLOR *scanln; |
543 |
> |
COLR rgbe; |
544 |
> |
int x, y; |
545 |
|
|
546 |
|
scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR)); |
547 |
|
if (scanln == NULL) { |
570 |
|
pow(colval(scanln[x],BLU), gamcor)); |
571 |
|
if (doexposure) |
572 |
|
multcolor(scanln[x], exposure); |
573 |
+ |
if (uniq) { /* uncompressed? */ |
574 |
+ |
setcolr(rgbe, scanln[x][RED], |
575 |
+ |
scanln[x][GRN], |
576 |
+ |
scanln[x][BLU]); |
577 |
+ |
if (putbinary(rgbe, sizeof(COLR), 1, stdout) != 1) |
578 |
+ |
goto writerr; |
579 |
+ |
} |
580 |
|
} |
581 |
< |
if (fwritescan(scanln, scanlen(&picres), stdout) < 0) { |
582 |
< |
fprintf(stderr, "%s: write error\n", progname); |
583 |
< |
quit(1); |
510 |
< |
} |
581 |
> |
/* write scan if compressed */ |
582 |
> |
if (!uniq && fwritescan(scanln, scanlen(&picres), stdout) < 0) |
583 |
> |
goto writerr; |
584 |
|
} |
585 |
|
free((void *)scanln); |
586 |
+ |
return; |
587 |
+ |
writerr: |
588 |
+ |
fprintf(stderr, "%s: write error\n", progname); |
589 |
+ |
quit(1); |
590 |
|
} |
591 |
|
|
592 |
|
|
627 |
|
double vd[3]; |
628 |
|
|
629 |
|
if (fin2 == NULL) { |
630 |
< |
if (fread((char *)vd, sizeof(double), 3, fin) != 3) |
630 |
> |
if (getbinary(vd, sizeof(double), 3, fin) != 3) |
631 |
|
return(-1); |
632 |
|
} else { |
633 |
< |
if (fread((char *)vd, sizeof(double), 1, fin) != 1 || |
634 |
< |
fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 || |
635 |
< |
fread((char *)(vd+2), sizeof(double), 1, fin3) != 1) |
633 |
> |
if (getbinary(vd, sizeof(double), 1, fin) != 1 || |
634 |
> |
getbinary(vd+1, sizeof(double), 1, fin2) != 1 || |
635 |
> |
getbinary(vd+2, sizeof(double), 1, fin3) != 1) |
636 |
|
return(-1); |
637 |
|
} |
638 |
|
if (swapbytes) |
650 |
|
float vf[3]; |
651 |
|
|
652 |
|
if (fin2 == NULL) { |
653 |
< |
if (fread((char *)vf, sizeof(float), 3, fin) != 3) |
653 |
> |
if (getbinary(vf, sizeof(float), 3, fin) != 3) |
654 |
|
return(-1); |
655 |
|
} else { |
656 |
< |
if (fread((char *)vf, sizeof(float), 1, fin) != 1 || |
657 |
< |
fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 || |
658 |
< |
fread((char *)(vf+2), sizeof(float), 1, fin3) != 1) |
656 |
> |
if (getbinary(vf, sizeof(float), 1, fin) != 1 || |
657 |
> |
getbinary(vf+1, sizeof(float), 1, fin2) != 1 || |
658 |
> |
getbinary(vf+2, sizeof(float), 1, fin3) != 1) |
659 |
|
return(-1); |
660 |
|
} |
661 |
|
if (swapbytes) |
692 |
|
COLOR col |
693 |
|
) |
694 |
|
{ |
695 |
< |
BYTE vb[3]; |
695 |
> |
uby8 vb[3]; |
696 |
|
|
697 |
|
if (fin2 == NULL) { |
698 |
< |
if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3) |
698 |
> |
if (getbinary(vb, sizeof(uby8), 3, fin) != 3) |
699 |
|
return(-1); |
700 |
|
} else { |
701 |
< |
if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 || |
702 |
< |
fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 || |
703 |
< |
fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1) |
701 |
> |
if (getbinary(vb, sizeof(uby8), 1, fin) != 1 || |
702 |
> |
getbinary(vb+1, sizeof(uby8), 1, fin2) != 1 || |
703 |
> |
getbinary(vb+2, sizeof(uby8), 1, fin3) != 1) |
704 |
|
return(-1); |
705 |
|
} |
706 |
|
setcolor(col, (vb[rord[RED]]+.5)/256., |
717 |
|
uint16 vw[3]; |
718 |
|
|
719 |
|
if (fin2 == NULL) { |
720 |
< |
if (fread((char *)vw, sizeof(uint16), 3, fin) != 3) |
720 |
> |
if (getbinary(vw, sizeof(uint16), 3, fin) != 3) |
721 |
|
return(-1); |
722 |
|
} else { |
723 |
< |
if (fread((char *)vw, sizeof(uint16), 1, fin) != 1 || |
724 |
< |
fread((char *)(vw+1), sizeof(uint16), 1, fin2) != 1 || |
725 |
< |
fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1) |
723 |
> |
if (getbinary(vw, sizeof(uint16), 1, fin) != 1 || |
724 |
> |
getbinary(vw+1, sizeof(uint16), 1, fin2) != 1 || |
725 |
> |
getbinary(vw+2, sizeof(uint16), 1, fin3) != 1) |
726 |
|
return(-1); |
727 |
|
} |
728 |
|
if (swapbytes) |
754 |
|
{ |
755 |
|
double vd; |
756 |
|
|
757 |
< |
if (fread((char *)&vd, sizeof(double), 1, fin) != 1) |
757 |
> |
if (getbinary(&vd, sizeof(double), 1, fin) != 1) |
758 |
|
return(-1); |
759 |
|
if (swapbytes) |
760 |
|
swap64((char *)&vd, 1); |
770 |
|
{ |
771 |
|
float vf; |
772 |
|
|
773 |
< |
if (fread((char *)&vf, sizeof(float), 1, fin) != 1) |
773 |
> |
if (getbinary(&vf, sizeof(float), 1, fin) != 1) |
774 |
|
return(-1); |
775 |
|
if (swapbytes) |
776 |
|
swap32((char *)&vf, 1); |
800 |
|
COLOR col |
801 |
|
) |
802 |
|
{ |
803 |
< |
BYTE vb; |
803 |
> |
uby8 vb; |
804 |
|
double d; |
805 |
|
|
806 |
< |
if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1) |
806 |
> |
if (getbinary(&vb, sizeof(uby8), 1, fin) != 1) |
807 |
|
return(-1); |
808 |
|
d = (vb+.5)/256.; |
809 |
|
setcolor(col, d, d, d); |
819 |
|
uint16 vw; |
820 |
|
double d; |
821 |
|
|
822 |
< |
if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1) |
822 |
> |
if (getbinary(&vw, sizeof(uint16), 1, fin) != 1) |
823 |
|
return(-1); |
824 |
|
if (swapbytes) |
825 |
|
swap16((char *)&vw, 1); |
855 |
|
vf[2] = colval(col,ord[2]); |
856 |
|
if (swapbytes) |
857 |
|
swap32((char *)vf, 3); |
858 |
< |
fwrite((char *)vf, sizeof(float), 3, stdout); |
858 |
> |
putbinary(vf, sizeof(float), 3, stdout); |
859 |
|
|
860 |
|
return(ferror(stdout) ? -1 : 0); |
861 |
|
} |
873 |
|
vd[2] = colval(col,ord[2]); |
874 |
|
if (swapbytes) |
875 |
|
swap64((char *)vd, 3); |
876 |
< |
fwrite((char *)vd, sizeof(double), 3, stdout); |
876 |
> |
putbinary(vd, sizeof(double), 3, stdout); |
877 |
|
|
878 |
|
return(ferror(stdout) ? -1 : 0); |
879 |
|
} |
899 |
|
) |
900 |
|
{ |
901 |
|
long i; |
902 |
< |
BYTE vb[3]; |
902 |
> |
uby8 vb[3]; |
903 |
|
|
904 |
|
i = colval(col,ord[0])*256.; |
905 |
|
vb[0] = min(i,255); |
907 |
|
vb[1] = min(i,255); |
908 |
|
i = colval(col,ord[2])*256.; |
909 |
|
vb[2] = min(i,255); |
910 |
< |
fwrite((char *)vb, sizeof(BYTE), 3, stdout); |
910 |
> |
putbinary(vb, sizeof(uby8), 3, stdout); |
911 |
|
|
912 |
|
return(ferror(stdout) ? -1 : 0); |
913 |
|
} |
929 |
|
vw[2] = min(i,65535); |
930 |
|
if (swapbytes) |
931 |
|
swap16((char *)vw, 3); |
932 |
< |
fwrite((char *)vw, sizeof(uint16), 3, stdout); |
932 |
> |
putbinary(vw, sizeof(uint16), 3, stdout); |
933 |
|
|
934 |
|
return(ferror(stdout) ? -1 : 0); |
935 |
|
} |
956 |
|
vf = (*mybright)(col); |
957 |
|
if (swapbytes) |
958 |
|
swap32((char *)&vf, 1); |
959 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
959 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
960 |
|
|
961 |
|
return(ferror(stdout) ? -1 : 0); |
962 |
|
} |
972 |
|
vd = (*mybright)(col); |
973 |
|
if (swapbytes) |
974 |
|
swap64((char *)&vd, 1); |
975 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
975 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
976 |
|
|
977 |
|
return(ferror(stdout) ? -1 : 0); |
978 |
|
} |
994 |
|
COLOR col |
995 |
|
) |
996 |
|
{ |
997 |
< |
register int i; |
998 |
< |
BYTE vb; |
997 |
> |
int i; |
998 |
> |
uby8 vb; |
999 |
|
|
1000 |
|
i = (*mybright)(col)*256.; |
1001 |
|
vb = min(i,255); |
1002 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
1002 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
1003 |
|
|
1004 |
|
return(ferror(stdout) ? -1 : 0); |
1005 |
|
} |
1017 |
|
vw = min(i,65535); |
1018 |
|
if (swapbytes) |
1019 |
|
swap16((char *)&vw, 1); |
1020 |
< |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
1020 |
> |
putbinary(&vw, sizeof(uint16), 1, stdout); |
1021 |
|
|
1022 |
|
return(ferror(stdout) ? -1 : 0); |
1023 |
|
} |
1044 |
|
vf = colval(col,putprim); |
1045 |
|
if (swapbytes) |
1046 |
|
swap32((char *)&vf, 1); |
1047 |
< |
fwrite((char *)&vf, sizeof(float), 1, stdout); |
1047 |
> |
putbinary(&vf, sizeof(float), 1, stdout); |
1048 |
|
|
1049 |
|
return(ferror(stdout) ? -1 : 0); |
1050 |
|
} |
1060 |
|
vd = colval(col,putprim); |
1061 |
|
if (swapbytes) |
1062 |
|
swap64((char *)&vd, 1); |
1063 |
< |
fwrite((char *)&vd, sizeof(double), 1, stdout); |
1063 |
> |
putbinary(&vd, sizeof(double), 1, stdout); |
1064 |
|
|
1065 |
|
return(ferror(stdout) ? -1 : 0); |
1066 |
|
} |
1083 |
|
) |
1084 |
|
{ |
1085 |
|
long i; |
1086 |
< |
BYTE vb; |
1086 |
> |
uby8 vb; |
1087 |
|
|
1088 |
|
i = colval(col,putprim)*256.; |
1089 |
|
vb = min(i,255); |
1090 |
< |
fwrite((char *)&vb, sizeof(BYTE), 1, stdout); |
1090 |
> |
putbinary(&vb, sizeof(uby8), 1, stdout); |
1091 |
|
|
1092 |
|
return(ferror(stdout) ? -1 : 0); |
1093 |
|
} |
1105 |
|
vw = min(i,65535); |
1106 |
|
if (swapbytes) |
1107 |
|
swap16((char *)&vw, 1); |
1108 |
< |
fwrite((char *)&vw, sizeof(uint16), 1, stdout); |
1108 |
> |
putbinary(&vw, sizeof(uint16), 1, stdout); |
1109 |
|
|
1110 |
|
return(ferror(stdout) ? -1 : 0); |
1111 |
|
} |
1147 |
|
if (fin2 == NULL) |
1148 |
|
goto namerr; |
1149 |
|
if (fseek(fin2, |
1150 |
< |
(long)sizeof(float)*picres.xr*picres.yr, 1)) |
1150 |
> |
(long)sizeof(float)*picres.xr*picres.yr, SEEK_CUR)) |
1151 |
|
goto seekerr; |
1152 |
|
if (fseek(fin3, |
1153 |
< |
(long)sizeof(float)*2*picres.xr*picres.yr, 1)) |
1153 |
> |
(long)sizeof(float)*2*picres.xr*picres.yr, SEEK_CUR)) |
1154 |
|
goto seekerr; |
1155 |
|
} |
1156 |
|
} |
1169 |
|
if (fin2 == NULL) |
1170 |
|
goto namerr; |
1171 |
|
if (fseek(fin2, |
1172 |
< |
(long)sizeof(double)*picres.xr*picres.yr, 1)) |
1172 |
> |
(long)sizeof(double)*picres.xr*picres.yr, SEEK_CUR)) |
1173 |
|
goto seekerr; |
1174 |
|
if (fseek(fin3, |
1175 |
< |
(long)sizeof(double)*2*picres.xr*picres.yr, 1)) |
1175 |
> |
(long)sizeof(double)*2*picres.xr*picres.yr, SEEK_CUR)) |
1176 |
|
goto seekerr; |
1177 |
|
} |
1178 |
|
} |
1209 |
|
if (fin2 == NULL) |
1210 |
|
goto namerr; |
1211 |
|
if (fseek(fin2, |
1212 |
< |
(long)sizeof(BYTE)*picres.xr*picres.yr, 1)) |
1212 |
> |
(long)sizeof(uby8)*picres.xr*picres.yr, SEEK_CUR)) |
1213 |
|
goto seekerr; |
1214 |
|
if (fseek(fin3, |
1215 |
< |
(long)sizeof(BYTE)*2*picres.xr*picres.yr, 1)) |
1215 |
> |
(long)sizeof(uby8)*2*picres.xr*picres.yr, SEEK_CUR)) |
1216 |
|
goto seekerr; |
1217 |
|
} |
1218 |
|
} |
1231 |
|
if (fin2 == NULL) |
1232 |
|
goto namerr; |
1233 |
|
if (fseek(fin2, |
1234 |
< |
(long)sizeof(uint16)*picres.xr*picres.yr, 1)) |
1234 |
> |
(long)sizeof(uint16)*picres.xr*picres.yr, SEEK_CUR)) |
1235 |
|
goto seekerr; |
1236 |
|
if (fseek(fin3, |
1237 |
< |
(long)sizeof(uint16)*2*picres.xr*picres.yr, 1)) |
1237 |
> |
(long)sizeof(uint16)*2*picres.xr*picres.yr, SEEK_CUR)) |
1238 |
|
goto seekerr; |
1239 |
|
} |
1240 |
|
} |