9 |
|
|
10 |
|
#include <stdio.h> |
11 |
|
#include <math.h> |
12 |
+ |
#include <ctype.h> |
13 |
|
#include <time.h> |
14 |
+ |
#include <string.h> |
15 |
+ |
|
16 |
+ |
#include "platform.h" |
17 |
|
#include "tiffio.h" |
18 |
|
#include "color.h" |
19 |
|
#include "resolu.h" |
31 |
|
#define C_TWRD 0x80 /* TIFF data is 16-bit */ |
32 |
|
#define C_PRIM 0x100 /* has assigned primaries */ |
33 |
|
|
34 |
+ |
typedef void colcvf_t(uint32 y); |
35 |
+ |
|
36 |
|
struct { |
37 |
|
uint16 flags; /* conversion flags (defined above) */ |
38 |
+ |
char capdate[20]; /* capture date/time */ |
39 |
+ |
char owner[256]; /* content owner */ |
40 |
|
uint16 comp; /* TIFF compression type */ |
41 |
|
uint16 phot; /* TIFF photometric type */ |
42 |
|
uint16 pconf; /* TIFF planar configuration */ |
61 |
|
float *fp; /* float pointer */ |
62 |
|
char *p; /* generic pointer */ |
63 |
|
} t; /* TIFF scanline */ |
64 |
< |
void (*tf)(); /* translation procedure */ |
64 |
> |
colcvf_t *tf; /* translation procedure */ |
65 |
|
} cvts = { /* conversion structure */ |
66 |
< |
0, COMPRESSION_NONE, PHOTOMETRIC_RGB, |
66 |
> |
0, "", "", COMPRESSION_NONE, PHOTOMETRIC_RGB, |
67 |
|
PLANARCONFIG_CONTIG, GAMCOR, 0, 1, 1., 1., |
68 |
|
}; |
69 |
|
|
72 |
|
#define CLR(f) (cvts.flags &= ~(f)) |
73 |
|
#define TGL(f) (cvts.flags ^= (f)) |
74 |
|
|
75 |
< |
void Luv2Color(), L2Color(), RGB2Colr(), Gry2Colr(); |
76 |
< |
void Color2Luv(), Color2L(), Colr2RGB(), Colr2Gry(); |
77 |
< |
void RRGGBB2Color(), GGry2Color(), Color2RRGGBB(), Color2GGry(); |
75 |
> |
static colcvf_t Luv2Color, L2Color, RGB2Colr, Gry2Colr; |
76 |
> |
static colcvf_t Color2Luv, Color2L, Colr2RGB, Colr2Gry; |
77 |
> |
static colcvf_t RRGGBB2Color, GGry2Color, Color2RRGGBB, Color2GGry; |
78 |
|
|
79 |
+ |
static gethfunc headline; |
80 |
+ |
static void quiterr(char *err); |
81 |
+ |
static void allocbufs(void); |
82 |
+ |
static void initfromtif(void); |
83 |
+ |
static void tiff2ra(int ac, char *av[]); |
84 |
+ |
static void initfromrad(void); |
85 |
+ |
static void ra2tiff(int ac, char *av[]); |
86 |
+ |
|
87 |
+ |
|
88 |
+ |
|
89 |
|
#define RfGfBf2Color Luv2Color |
90 |
|
#define Gryf2Color L2Color |
91 |
|
#define Color2Gryf Color2L |
104 |
|
|
105 |
|
#define pixorder() ortab[cvts.orient-1] |
106 |
|
|
107 |
+ |
extern char TMSTR[]; /* "CAPDATE=" from header.c */ |
108 |
+ |
char OWNSTR[] = "OWNER="; |
109 |
+ |
|
110 |
|
char *progname; |
111 |
|
|
112 |
|
|
113 |
< |
main(argc, argv) |
114 |
< |
int argc; |
94 |
< |
char *argv[]; |
113 |
> |
int |
114 |
> |
main(int argc, char *argv[]) |
115 |
|
{ |
116 |
|
int reverse = 0; |
117 |
|
int i; |
175 |
|
if (i != argc-2) |
176 |
|
goto userr; |
177 |
|
/* consistency checks */ |
178 |
< |
if (CHK(C_GRY)) |
178 |
> |
if (CHK(C_GRY)) { |
179 |
|
if (cvts.phot == PHOTOMETRIC_RGB) |
180 |
|
cvts.phot = PHOTOMETRIC_MINISBLACK; |
181 |
|
else { |
182 |
|
cvts.phot = PHOTOMETRIC_LOGL; |
183 |
|
cvts.comp = COMPRESSION_SGILOG; |
184 |
|
} |
185 |
+ |
} |
186 |
|
if (CHK(C_TWRD|C_TFLT) == (C_TWRD|C_TFLT)) |
187 |
|
goto userr; |
188 |
|
|
192 |
|
exit(0); |
193 |
|
userr: |
194 |
|
fprintf(stderr, |
195 |
< |
"Usage: %s [-z|-L|-l|-f|-w][-b][-e +/-stops][-g gamma] {in.pic|-} out.tif\n", |
195 |
> |
"Usage: %s [-z|-L|-l|-f|-w][-b][-e +/-stops][-g gamma] {in.hdr|-} out.tif\n", |
196 |
|
progname); |
197 |
|
fprintf(stderr, |
198 |
< |
" Or: %s -r [-x][-e +/-stops][-g gamma] in.tif [out.pic|-]\n", |
198 |
> |
" Or: %s -r [-x][-e +/-stops][-g gamma] in.tif [out.hdr|-]\n", |
199 |
|
progname); |
200 |
|
exit(1); |
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
< |
quiterr(err) /* print message and exit */ |
205 |
< |
char *err; |
204 |
> |
static void |
205 |
> |
quiterr( /* print message and exit */ |
206 |
> |
char *err |
207 |
> |
) |
208 |
|
{ |
209 |
|
if (err != NULL) { |
210 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
< |
allocbufs() /* allocate scanline buffers */ |
217 |
> |
static void |
218 |
> |
allocbufs(void) /* allocate scanline buffers */ |
219 |
|
{ |
220 |
|
int rsiz, tsiz; |
221 |
|
|
225 |
|
(CHK(C_GRY) ? 1 : 3); |
226 |
|
cvts.r.p = (char *)malloc(rsiz*cvts.xmax); |
227 |
|
cvts.t.p = (char *)malloc(tsiz*cvts.xmax); |
228 |
< |
if (cvts.r.p == NULL | cvts.t.p == NULL) |
228 |
> |
if ((cvts.r.p == NULL) | (cvts.t.p == NULL)) |
229 |
|
quiterr("no memory to allocate scanline buffers"); |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
< |
initfromtif() /* initialize conversion from TIFF input */ |
233 |
> |
static void |
234 |
> |
initfromtif(void) /* initialize conversion from TIFF input */ |
235 |
|
{ |
236 |
|
uint16 hi; |
237 |
+ |
char *cp; |
238 |
|
float *fa, f1, f2; |
239 |
|
|
240 |
|
CLR(C_GRY|C_GAMMA|C_PRIM|C_RFLT|C_TFLT|C_TWRD|C_CXFM); |
276 |
|
cpcolormat(cvts.cmat, xyz2rgbmat); |
277 |
|
SET(C_CXFM|C_GAMUT); |
278 |
|
} else if (cvts.comp == COMPRESSION_SGILOG) |
279 |
< |
SET(C_GAMUT); |
279 |
> |
SET(C_GAMUT); /* may be outside XYZ gamut */ |
280 |
|
if (cvts.pconf != PLANARCONFIG_CONTIG) |
281 |
|
quiterr("cannot handle separate Luv planes"); |
282 |
|
TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, |
363 |
|
quiterr("unknown input image resolution"); |
364 |
|
|
365 |
|
if (!TIFFGetField(cvts.tif, TIFFTAG_STONITS, &cvts.stonits)) |
366 |
< |
cvts.stonits = 1.; |
366 |
> |
cvts.stonits = -1.; |
367 |
> |
|
368 |
> |
if (!TIFFGetField(cvts.tif, TIFFTAG_DATETIME, &cp)) |
369 |
> |
cvts.capdate[0] = '\0'; |
370 |
> |
else { |
371 |
> |
strncpy(cvts.capdate, cp, 19); |
372 |
> |
cvts.capdate[19] = '\0'; |
373 |
> |
} |
374 |
> |
if (!TIFFGetField(cvts.tif, TIFFTAG_ARTIST, &cp)) |
375 |
> |
cvts.owner[0] = '\0'; |
376 |
> |
else { |
377 |
> |
strncpy(cvts.owner, cp, sizeof(cvts.owner)); |
378 |
> |
cvts.owner[sizeof(cvts.owner)-1] = '\0'; |
379 |
> |
} |
380 |
|
/* add to Radiance header */ |
381 |
|
if (cvts.pixrat < .99 || cvts.pixrat > 1.01) |
382 |
|
fputaspect(cvts.pixrat, cvts.rfp); |
383 |
|
if (CHK(C_XYZE)) { |
384 |
< |
fputexpos(pow(2.,(double)cvts.bradj)/cvts.stonits, cvts.rfp); |
384 |
> |
if (cvts.stonits > .0) |
385 |
> |
fputexpos(pow(2.,(double)cvts.bradj)/cvts.stonits, cvts.rfp); |
386 |
|
fputformat(CIEFMT, cvts.rfp); |
387 |
|
} else { |
388 |
|
if (CHK(C_PRIM)) |
389 |
|
fputprims(cvts.prims, cvts.rfp); |
390 |
< |
fputexpos(WHTEFFICACY*pow(2.,(double)cvts.bradj)/cvts.stonits, |
391 |
< |
cvts.rfp); |
390 |
> |
if (cvts.stonits > .0) |
391 |
> |
fputexpos(WHTEFFICACY*pow(2.,(double)cvts.bradj)/cvts.stonits, |
392 |
> |
cvts.rfp); |
393 |
|
fputformat(COLRFMT, cvts.rfp); |
394 |
|
} |
395 |
+ |
if (cvts.capdate[0]) |
396 |
+ |
fprintf(cvts.rfp, "%s %s\n", TMSTR, cvts.capdate); |
397 |
+ |
if (cvts.owner[0]) |
398 |
+ |
fprintf(cvts.rfp, "%s %s\n", OWNSTR, cvts.owner); |
399 |
|
|
400 |
|
allocbufs(); /* allocate scanline buffers */ |
401 |
|
} |
402 |
|
|
403 |
|
|
404 |
< |
tiff2ra(ac, av) /* convert TIFF image to Radiance picture */ |
405 |
< |
int ac; |
406 |
< |
char *av[]; |
404 |
> |
static void |
405 |
> |
tiff2ra( /* convert TIFF image to Radiance picture */ |
406 |
> |
int ac, |
407 |
> |
char *av[] |
408 |
> |
) |
409 |
|
{ |
410 |
|
int32 y; |
411 |
|
/* open TIFF input */ |
416 |
|
cvts.rfp = stdout; |
417 |
|
else if ((cvts.rfp = fopen(av[ac+1], "w")) == NULL) |
418 |
|
quiterr("cannot open Radiance output picture"); |
419 |
+ |
SET_FILE_BINARY(cvts.rfp); |
420 |
|
/* start output header */ |
421 |
|
newheader("RADIANCE", cvts.rfp); |
422 |
|
printargs(ac, av, cvts.rfp); |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
< |
int |
438 |
< |
headline(s) /* process Radiance input header line */ |
439 |
< |
char *s; |
437 |
> |
static int |
438 |
> |
headline( /* process Radiance input header line */ |
439 |
> |
char *s, |
440 |
> |
void *p |
441 |
> |
) |
442 |
|
{ |
443 |
< |
char fmt[32]; |
443 |
> |
static int tmstrlen = 0; |
444 |
> |
static int ownstrlen = 0; |
445 |
> |
char fmt[MAXFMTLEN]; |
446 |
|
|
447 |
+ |
if (!tmstrlen) |
448 |
+ |
tmstrlen = strlen(TMSTR); |
449 |
+ |
if (!ownstrlen) |
450 |
+ |
ownstrlen = strlen(OWNSTR); |
451 |
|
if (formatval(fmt, s)) { |
452 |
|
if (!strcmp(fmt, COLRFMT)) |
453 |
|
CLR(C_XYZE); |
470 |
|
SET(C_PRIM); |
471 |
|
return(1); |
472 |
|
} |
473 |
+ |
if (isdate(s)) { |
474 |
+ |
if (s[tmstrlen] == ' ') |
475 |
+ |
strncpy(cvts.capdate, s+tmstrlen+1, 19); |
476 |
+ |
else |
477 |
+ |
strncpy(cvts.capdate, s+tmstrlen, 19); |
478 |
+ |
cvts.capdate[19] = '\0'; |
479 |
+ |
return(1); |
480 |
+ |
} |
481 |
+ |
if (!strncmp(s, OWNSTR, ownstrlen)) { |
482 |
+ |
register char *cp = s + ownstrlen; |
483 |
+ |
|
484 |
+ |
while (isspace(*cp)) |
485 |
+ |
++cp; |
486 |
+ |
strncpy(cvts.owner, cp, sizeof(cvts.owner)); |
487 |
+ |
cvts.owner[sizeof(cvts.owner)-1] = '\0'; |
488 |
+ |
for (cp = cvts.owner; *cp; cp++) |
489 |
+ |
; |
490 |
+ |
while (cp > cvts.owner && isspace(cp[-1])) |
491 |
+ |
*--cp = '\0'; |
492 |
+ |
return(1); |
493 |
+ |
} |
494 |
|
return(0); |
495 |
|
} |
496 |
|
|
497 |
|
|
498 |
< |
initfromrad() /* initialize input from a Radiance picture */ |
498 |
> |
static void |
499 |
> |
initfromrad(void) /* initialize input from a Radiance picture */ |
500 |
|
{ |
501 |
|
int i1, i2, po; |
502 |
|
/* read Radiance header */ |
503 |
|
CLR(C_RFLT|C_XYZE|C_PRIM|C_GAMMA|C_CXFM); |
504 |
+ |
cvts.capdate[0] = '\0'; |
505 |
+ |
cvts.owner[0] = '\0'; |
506 |
|
cvts.stonits = 1.; |
507 |
|
cvts.pixrat = 1.; |
508 |
|
cvts.pconf = PLANARCONFIG_CONTIG; |
569 |
|
cvts.tf = Color2RRGGBB; |
570 |
|
SET(C_RFLT); |
571 |
|
} else if (CHK(C_TFLT)) { |
572 |
+ |
TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, |
573 |
+ |
SAMPLEFORMAT_IEEEFP); |
574 |
|
cvts.tf = Color2RfGfBf; |
575 |
|
SET(C_RFLT); |
576 |
+ |
CLR(C_GAMUT); |
577 |
|
} else |
578 |
|
cvts.tf = Colr2RGB; |
579 |
|
break; |
584 |
|
cvts.tf = Color2GGry; |
585 |
|
SET(C_RFLT); |
586 |
|
} else if (CHK(C_TFLT)) { |
587 |
+ |
TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, |
588 |
+ |
SAMPLEFORMAT_IEEEFP); |
589 |
|
cvts.tf = Color2Gryf; |
590 |
|
SET(C_RFLT); |
591 |
|
} else |
608 |
|
TIFFSetField(cvts.tif, TIFFTAG_PLANARCONFIG, cvts.pconf); |
609 |
|
TIFFSetField(cvts.tif, TIFFTAG_STONITS, |
610 |
|
cvts.stonits/pow(2.,(double)cvts.bradj)); |
611 |
+ |
if (cvts.capdate[0]) |
612 |
+ |
TIFFSetField(cvts.tif, TIFFTAG_DATETIME, cvts.capdate); |
613 |
+ |
if (cvts.owner[0]) |
614 |
+ |
TIFFSetField(cvts.tif, TIFFTAG_ARTIST, cvts.owner); |
615 |
|
if (cvts.comp == COMPRESSION_NONE) |
616 |
|
i1 = TIFFScanlineSize(cvts.tif); |
617 |
|
else |
624 |
|
} |
625 |
|
|
626 |
|
|
627 |
< |
ra2tiff(ac, av) /* convert Radiance picture to TIFF image */ |
628 |
< |
int ac; |
629 |
< |
char *av[]; |
627 |
> |
static void |
628 |
> |
ra2tiff( /* convert Radiance picture to TIFF image */ |
629 |
> |
int ac, |
630 |
> |
char *av[] |
631 |
> |
) |
632 |
|
{ |
633 |
|
uint32 y; |
634 |
|
/* open Radiance file */ |
636 |
|
cvts.rfp = stdin; |
637 |
|
else if ((cvts.rfp = fopen(av[ac], "r")) == NULL) |
638 |
|
quiterr("cannot open Radiance input picture"); |
639 |
+ |
SET_FILE_BINARY(cvts.rfp); |
640 |
|
/* open TIFF file */ |
641 |
|
if ((cvts.tif = TIFFOpen(av[ac+1], "w")) == NULL) |
642 |
|
quiterr("cannot open TIFF output"); |
651 |
|
} |
652 |
|
|
653 |
|
|
654 |
< |
void |
655 |
< |
Luv2Color(y) /* read/convert/write Luv->COLOR scanline */ |
656 |
< |
uint32 y; |
654 |
> |
static void |
655 |
> |
Luv2Color( /* read/convert/write Luv->COLOR scanline */ |
656 |
> |
uint32 y |
657 |
> |
) |
658 |
|
{ |
659 |
|
register int x; |
660 |
|
|
661 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT)) |
662 |
|
quiterr("internal error 1 in Luv2Color"); |
663 |
|
|
664 |
+ |
if (cvts.pconf != PLANARCONFIG_CONTIG) |
665 |
+ |
quiterr("cannot handle separate 32-bit color planes"); |
666 |
+ |
|
667 |
|
if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
668 |
|
quiterr("error reading TIFF input"); |
669 |
|
/* also works for float RGB */ |
690 |
|
} |
691 |
|
|
692 |
|
|
693 |
< |
void |
694 |
< |
RRGGBB2Color(y) /* read/convert/write RGB16->COLOR scanline */ |
695 |
< |
uint32 y; |
693 |
> |
static void |
694 |
> |
RRGGBB2Color( /* read/convert/write RGB16->COLOR scanline */ |
695 |
> |
uint32 y |
696 |
> |
) |
697 |
|
{ |
698 |
< |
int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; |
698 |
> |
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
699 |
|
register double d; |
700 |
|
register int x; |
701 |
|
|
702 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_TWRD|C_RFLT)) |
703 |
|
quiterr("internal error 1 in RRGGBB2Color"); |
704 |
|
|
705 |
+ |
if (cvts.pconf != PLANARCONFIG_CONTIG) |
706 |
+ |
quiterr("cannot handle separate 16-bit color planes"); |
707 |
+ |
|
708 |
|
if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
709 |
|
quiterr("error reading TIFF input"); |
710 |
|
|
721 |
|
if (CHK(C_CXFM)) |
722 |
|
colortrans(cvts.r.colors[x], cvts.cmat, |
723 |
|
cvts.r.colors[x]); |
624 |
– |
if (CHK(C_GAMUT)) |
625 |
– |
clipgamut(cvts.r.colors[x], cvts.t.fp[3*x + 1], |
626 |
– |
CGAMUT_LOWER, cblack, cwhite); |
724 |
|
} |
725 |
|
if (cvts.bradj) { |
726 |
|
d = pow(2.,(double)cvts.bradj); |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
< |
void |
737 |
< |
L2Color(y) /* read/convert/write Lfloat->COLOR scanline */ |
738 |
< |
uint32 y; |
736 |
> |
static void |
737 |
> |
L2Color( /* read/convert/write Lfloat->COLOR scanline */ |
738 |
> |
uint32 y |
739 |
> |
) |
740 |
|
{ |
741 |
|
float m = pow(2., (double)cvts.bradj); |
742 |
|
register int x; |
757 |
|
} |
758 |
|
|
759 |
|
|
760 |
< |
void |
761 |
< |
RGB2Colr(y) /* read/convert/write RGB->COLR scanline */ |
762 |
< |
uint32 y; |
760 |
> |
static void |
761 |
> |
RGB2Colr( /* read/convert/write RGB->COLR scanline */ |
762 |
> |
uint32 y |
763 |
> |
) |
764 |
|
{ |
765 |
|
COLOR ctmp; |
766 |
|
register int x; |
814 |
|
} |
815 |
|
|
816 |
|
|
817 |
< |
void |
818 |
< |
Gry2Colr(y) /* read/convert/write G8->COLR scanline */ |
819 |
< |
uint32 y; |
817 |
> |
static void |
818 |
> |
Gry2Colr( /* read/convert/write G8->COLR scanline */ |
819 |
> |
uint32 y |
820 |
> |
) |
821 |
|
{ |
822 |
|
register int x; |
823 |
|
|
841 |
|
} |
842 |
|
|
843 |
|
|
844 |
< |
void |
845 |
< |
GGry2Color(y) /* read/convert/write G16->COLOR scanline */ |
846 |
< |
uint32 y; |
844 |
> |
static void |
845 |
> |
GGry2Color( /* read/convert/write G16->COLOR scanline */ |
846 |
> |
uint32 y |
847 |
> |
) |
848 |
|
{ |
849 |
< |
int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; |
849 |
> |
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
850 |
|
double m; |
851 |
|
register double d; |
852 |
|
register int x; |
872 |
|
} |
873 |
|
|
874 |
|
|
875 |
< |
void |
876 |
< |
Color2GGry(y) /* read/convert/write COLOR->G16 scanline */ |
877 |
< |
uint32 y; |
875 |
> |
static void |
876 |
> |
Color2GGry( /* read/convert/write COLOR->G16 scanline */ |
877 |
> |
uint32 y |
878 |
> |
) |
879 |
|
{ |
880 |
< |
int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; |
880 |
> |
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
881 |
|
float m = pow(2.,(double)cvts.bradj); |
882 |
|
register int x; |
883 |
|
|
907 |
|
} |
908 |
|
|
909 |
|
|
910 |
< |
void |
911 |
< |
Color2L(y) /* read/convert/write COLOR->Lfloat scanline */ |
912 |
< |
uint32 y; |
910 |
> |
static void |
911 |
> |
Color2L( /* read/convert/write COLOR->Lfloat scanline */ |
912 |
> |
uint32 y |
913 |
> |
) |
914 |
|
{ |
915 |
|
float m = pow(2.,(double)cvts.bradj); |
916 |
|
register int x; |
930 |
|
} |
931 |
|
|
932 |
|
|
933 |
< |
void |
934 |
< |
Color2Luv(y) /* read/convert/write COLOR->Luv scanline */ |
935 |
< |
uint32 y; |
933 |
> |
static void |
934 |
> |
Color2Luv( /* read/convert/write COLOR->Luv scanline */ |
935 |
> |
uint32 y |
936 |
> |
) |
937 |
|
{ |
938 |
|
register int x; |
939 |
|
|
964 |
|
} |
965 |
|
|
966 |
|
|
967 |
< |
void |
968 |
< |
Color2RRGGBB(y) /* read/convert/write COLOR->RGB16 scanline */ |
969 |
< |
uint32 y; |
967 |
> |
static void |
968 |
> |
Color2RRGGBB( /* read/convert/write COLOR->RGB16 scanline */ |
969 |
> |
uint32 y |
970 |
> |
) |
971 |
|
{ |
972 |
< |
int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; |
972 |
> |
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
973 |
|
float m = pow(2.,(double)cvts.bradj); |
974 |
|
register int x, i; |
975 |
|
|
979 |
|
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
980 |
|
quiterr("error reading Radiance picture"); |
981 |
|
|
982 |
< |
for (x = cvts.xmax; x--; ) |
982 |
> |
for (x = cvts.xmax; x--; ) { |
983 |
> |
if (CHK(C_CXFM)) { |
984 |
> |
colortrans(cvts.r.colors[x], cvts.cmat, |
985 |
> |
cvts.r.colors[x]); |
986 |
> |
if (CHK(C_GAMUT)) |
987 |
> |
clipgamut(cvts.r.colors[x], bright(cvts.r.colors[x]), |
988 |
> |
CGAMUT_LOWER, cblack, cwhite); |
989 |
> |
} |
990 |
|
for (i = 3; i--; ) { |
991 |
|
register float f = m*colval(cvts.r.colors[x],i); |
992 |
|
if (f <= 0) |
999 |
|
else |
1000 |
|
cvts.t.wp[3*x + i] = (int)((float)(1L<<16)*f); |
1001 |
|
} |
1002 |
+ |
} |
1003 |
|
|
1004 |
|
if (TIFFWriteScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
1005 |
|
quiterr("error writing TIFF output"); |
1006 |
|
} |
1007 |
|
|
1008 |
|
|
1009 |
< |
void |
1010 |
< |
Colr2Gry(y) /* read/convert/write COLR->RGB scanline */ |
1011 |
< |
uint32 y; |
1009 |
> |
static void |
1010 |
> |
Colr2Gry( /* read/convert/write COLR->RGB scanline */ |
1011 |
> |
uint32 y |
1012 |
> |
) |
1013 |
|
{ |
1014 |
|
register int x; |
1015 |
|
|
1033 |
|
} |
1034 |
|
|
1035 |
|
|
1036 |
< |
void |
1037 |
< |
Colr2RGB(y) /* read/convert/write COLR->RGB scanline */ |
1038 |
< |
uint32 y; |
1036 |
> |
static void |
1037 |
> |
Colr2RGB( /* read/convert/write COLR->RGB scanline */ |
1038 |
> |
uint32 y |
1039 |
> |
) |
1040 |
|
{ |
1041 |
|
COLOR ctmp; |
1042 |
|
register int x; |