7 |
|
* Added white-balance adjustment 10/01 (GW). |
8 |
|
*/ |
9 |
|
|
10 |
– |
#include <stdio.h> |
10 |
|
#include <math.h> |
11 |
|
#include <ctype.h> |
13 |
– |
#include <time.h> |
14 |
– |
#include <string.h> |
12 |
|
|
13 |
+ |
#include "rtio.h" |
14 |
+ |
#include "platform.h" |
15 |
|
#include "tiffio.h" |
16 |
|
#include "color.h" |
17 |
|
#include "resolu.h" |
24 |
|
#define C_GAMMA 0x4 /* needs gamma correction */ |
25 |
|
#define C_GRY 0x8 /* TIFF is greyscale */ |
26 |
|
#define C_XYZE 0x10 /* Radiance is XYZE */ |
27 |
< |
#define C_RFLT 0x20 /* Radiance data is float */ |
28 |
< |
#define C_TFLT 0x40 /* TIFF data is float */ |
29 |
< |
#define C_TWRD 0x80 /* TIFF data is 16-bit */ |
30 |
< |
#define C_PRIM 0x100 /* has assigned primaries */ |
27 |
> |
#define C_SPEC 0x20 /* Radiance is spectral */ |
28 |
> |
#define C_RFLT 0x40 /* Radiance data is float */ |
29 |
> |
#define C_TFLT 0x80 /* TIFF data is float */ |
30 |
> |
#define C_TWRD 0x100 /* TIFF data is 16-bit */ |
31 |
> |
#define C_PRIM 0x200 /* has assigned primaries */ |
32 |
|
|
33 |
|
typedef void colcvf_t(uint32 y); |
34 |
|
|
35 |
< |
struct { |
35 |
> |
struct CONVST { |
36 |
|
uint16 flags; /* conversion flags (defined above) */ |
37 |
|
char capdate[20]; /* capture date/time */ |
38 |
|
char owner[256]; /* content owner */ |
44 |
|
uint16 orient; /* visual orientation (TIFF spec.) */ |
45 |
|
double stonits; /* input conversion to nits */ |
46 |
|
float pixrat; /* pixel aspect ratio */ |
47 |
+ |
int ncc; /* # color components for spectral */ |
48 |
+ |
float wpt[4]; /* wavelength partitions */ |
49 |
|
FILE *rfp; /* Radiance stream pointer */ |
50 |
|
TIFF *tif; /* TIFF pointer */ |
51 |
|
uint32 xmax, ymax; /* image dimensions */ |
54 |
|
union { |
55 |
|
COLR *colrs; /* 4-byte ???E pointer */ |
56 |
|
COLOR *colors; /* float array pointer */ |
57 |
< |
char *p; /* generic pointer */ |
57 |
> |
void *p; /* generic pointer */ |
58 |
|
} r; /* Radiance scanline */ |
59 |
|
union { |
60 |
|
uint8 *bp; /* byte pointer */ |
61 |
|
uint16 *wp; /* word pointer */ |
62 |
|
float *fp; /* float pointer */ |
63 |
< |
char *p; /* generic pointer */ |
63 |
> |
void *p; /* generic pointer */ |
64 |
|
} t; /* TIFF scanline */ |
65 |
|
colcvf_t *tf; /* translation procedure */ |
66 |
|
} cvts = { /* conversion structure */ |
67 |
|
0, "", "", COMPRESSION_NONE, PHOTOMETRIC_RGB, |
68 |
< |
PLANARCONFIG_CONTIG, GAMCOR, 0, 1, 1., 1., |
68 |
> |
PLANARCONFIG_CONTIG, GAMCOR, 0, 1, 1., 1., 3, |
69 |
|
}; |
70 |
|
|
71 |
|
#define CHK(f) (cvts.flags & (f)) |
84 |
|
static void tiff2ra(int ac, char *av[]); |
85 |
|
static void initfromrad(void); |
86 |
|
static void ra2tiff(int ac, char *av[]); |
87 |
+ |
static void ReadRadScan(struct CONVST *cvp); |
88 |
|
|
89 |
|
|
87 |
– |
|
90 |
|
#define RfGfBf2Color Luv2Color |
91 |
|
#define Gryf2Color L2Color |
92 |
|
#define Color2Gryf Color2L |
193 |
|
exit(0); |
194 |
|
userr: |
195 |
|
fprintf(stderr, |
196 |
< |
"Usage: %s [-z|-L|-l|-f|-w][-b][-e +/-stops][-g gamma] {in.pic|-} out.tif\n", |
196 |
> |
"Usage: %s [-z|-L|-l|-f|-w][-b][-e +/-stops][-g gamma] {in.hdr|-} out.tif\n", |
197 |
|
progname); |
198 |
|
fprintf(stderr, |
199 |
< |
" Or: %s -r [-x][-e +/-stops][-g gamma] in.tif [out.pic|-]\n", |
199 |
> |
" Or: %s -r [-x][-e +/-stops][-g gamma] in.tif [out.hdr|-]\n", |
200 |
|
progname); |
201 |
|
exit(1); |
202 |
|
} |
224 |
|
tsiz = (CHK(C_TFLT) ? sizeof(float) : |
225 |
|
CHK(C_TWRD) ? sizeof(uint16) : sizeof(uint8)) * |
226 |
|
(CHK(C_GRY) ? 1 : 3); |
227 |
< |
cvts.r.p = (char *)malloc(rsiz*cvts.xmax); |
228 |
< |
cvts.t.p = (char *)malloc(tsiz*cvts.xmax); |
227 |
> |
cvts.r.p = malloc(rsiz*cvts.xmax); |
228 |
> |
cvts.t.p = malloc(tsiz*cvts.xmax); |
229 |
|
if ((cvts.r.p == NULL) | (cvts.t.p == NULL)) |
230 |
|
quiterr("no memory to allocate scanline buffers"); |
231 |
|
} |
238 |
|
char *cp; |
239 |
|
float *fa, f1, f2; |
240 |
|
|
239 |
– |
CLR(C_GRY|C_GAMMA|C_PRIM|C_RFLT|C_TFLT|C_TWRD|C_CXFM); |
240 |
– |
|
241 |
|
TIFFGetFieldDefaulted(cvts.tif, TIFFTAG_PLANARCONFIG, &cvts.pconf); |
242 |
|
|
243 |
|
if (TIFFGetField(cvts.tif, TIFFTAG_PRIMARYCHROMATICITIES, &fa)) { |
362 |
|
quiterr("unknown input image resolution"); |
363 |
|
|
364 |
|
if (!TIFFGetField(cvts.tif, TIFFTAG_STONITS, &cvts.stonits)) |
365 |
< |
cvts.stonits = 1.; |
365 |
> |
cvts.stonits = -1.; |
366 |
|
|
367 |
|
if (!TIFFGetField(cvts.tif, TIFFTAG_DATETIME, &cp)) |
368 |
|
cvts.capdate[0] = '\0'; |
380 |
|
if (cvts.pixrat < .99 || cvts.pixrat > 1.01) |
381 |
|
fputaspect(cvts.pixrat, cvts.rfp); |
382 |
|
if (CHK(C_XYZE)) { |
383 |
< |
fputexpos(pow(2.,(double)cvts.bradj)/cvts.stonits, cvts.rfp); |
383 |
> |
if (cvts.stonits > .0) |
384 |
> |
fputexpos(pow(2.,(double)cvts.bradj)/cvts.stonits, cvts.rfp); |
385 |
|
fputformat(CIEFMT, cvts.rfp); |
386 |
|
} else { |
387 |
|
if (CHK(C_PRIM)) |
388 |
|
fputprims(cvts.prims, cvts.rfp); |
389 |
< |
fputexpos(WHTEFFICACY*pow(2.,(double)cvts.bradj)/cvts.stonits, |
390 |
< |
cvts.rfp); |
389 |
> |
if (cvts.stonits > .0) |
390 |
> |
fputexpos(WHTEFFICACY*pow(2.,(double)cvts.bradj)/cvts.stonits, |
391 |
> |
cvts.rfp); |
392 |
|
fputformat(COLRFMT, cvts.rfp); |
393 |
|
} |
394 |
|
if (cvts.capdate[0]) |
415 |
|
cvts.rfp = stdout; |
416 |
|
else if ((cvts.rfp = fopen(av[ac+1], "w")) == NULL) |
417 |
|
quiterr("cannot open Radiance output picture"); |
418 |
+ |
SET_FILE_BINARY(cvts.rfp); |
419 |
|
/* start output header */ |
420 |
|
newheader("RADIANCE", cvts.rfp); |
421 |
|
printargs(ac, av, cvts.rfp); |
441 |
|
{ |
442 |
|
static int tmstrlen = 0; |
443 |
|
static int ownstrlen = 0; |
444 |
< |
char fmt[32]; |
444 |
> |
struct CONVST *cvp = (struct CONVST *)p; |
445 |
> |
char fmt[MAXFMTLEN]; |
446 |
|
|
447 |
< |
if (!tmstrlen) |
447 |
> |
if (!tmstrlen) { |
448 |
|
tmstrlen = strlen(TMSTR); |
445 |
– |
if (!ownstrlen) |
449 |
|
ownstrlen = strlen(OWNSTR); |
450 |
+ |
} |
451 |
|
if (formatval(fmt, s)) { |
452 |
< |
if (!strcmp(fmt, COLRFMT)) |
453 |
< |
CLR(C_XYZE); |
450 |
< |
else if (!strcmp(fmt, CIEFMT)) |
452 |
> |
CLR(C_XYZE|C_SPEC); |
453 |
> |
if (!strcmp(fmt, CIEFMT)) |
454 |
|
SET(C_XYZE); |
455 |
< |
else |
456 |
< |
quiterr("unrecognized input picture format"); |
455 |
> |
else if (!strcmp(fmt, SPECFMT)) |
456 |
> |
SET(C_SPEC); |
457 |
> |
else if (strcmp(fmt, COLRFMT)) |
458 |
> |
return(-1); |
459 |
|
return(1); |
460 |
|
} |
461 |
|
if (isexpos(s)) { |
462 |
< |
cvts.stonits /= exposval(s); |
462 |
> |
cvp->stonits /= exposval(s); |
463 |
|
return(1); |
464 |
|
} |
465 |
|
if (isaspect(s)) { |
466 |
< |
cvts.pixrat *= aspectval(s); |
466 |
> |
cvp->pixrat *= aspectval(s); |
467 |
|
return(1); |
468 |
|
} |
469 |
|
if (isprims(s)) { |
470 |
< |
primsval(cvts.prims, s); |
470 |
> |
primsval(cvp->prims, s); |
471 |
|
SET(C_PRIM); |
472 |
|
return(1); |
473 |
|
} |
474 |
|
if (isdate(s)) { |
475 |
|
if (s[tmstrlen] == ' ') |
476 |
< |
strncpy(cvts.capdate, s+tmstrlen+1, 19); |
476 |
> |
strncpy(cvp->capdate, s+tmstrlen+1, 19); |
477 |
|
else |
478 |
< |
strncpy(cvts.capdate, s+tmstrlen, 19); |
479 |
< |
cvts.capdate[19] = '\0'; |
478 |
> |
strncpy(cvp->capdate, s+tmstrlen, 19); |
479 |
> |
cvp->capdate[19] = '\0'; |
480 |
|
return(1); |
481 |
|
} |
482 |
|
if (!strncmp(s, OWNSTR, ownstrlen)) { |
483 |
< |
register char *cp = s + ownstrlen; |
483 |
> |
char *cp = s + ownstrlen; |
484 |
|
|
485 |
|
while (isspace(*cp)) |
486 |
|
++cp; |
487 |
< |
strncpy(cvts.owner, cp, sizeof(cvts.owner)); |
488 |
< |
cvts.owner[sizeof(cvts.owner)-1] = '\0'; |
489 |
< |
for (cp = cvts.owner; *cp; cp++) |
487 |
> |
strncpy(cvp->owner, cp, sizeof(cvp->owner)); |
488 |
> |
cvp->owner[sizeof(cvp->owner)-1] = '\0'; |
489 |
> |
for (cp = cvp->owner; *cp; cp++) |
490 |
|
; |
491 |
< |
while (cp > cvts.owner && isspace(cp[-1])) |
491 |
> |
while (cp > cvp->owner && isspace(cp[-1])) |
492 |
|
*--cp = '\0'; |
493 |
|
return(1); |
494 |
|
} |
495 |
+ |
if (isncomp(s)) { |
496 |
+ |
cvp->ncc = ncompval(s); |
497 |
+ |
return((3 <= cvp->ncc) & (cvp->ncc < MAXCSAMP) ? 1 : -1); |
498 |
+ |
} |
499 |
+ |
if (iswlsplit(s)) |
500 |
+ |
return(wlsplitval(cvp->wpt, s) ? 1 : -1); |
501 |
|
return(0); |
502 |
|
} |
503 |
|
|
507 |
|
{ |
508 |
|
int i1, i2, po; |
509 |
|
/* read Radiance header */ |
510 |
< |
CLR(C_RFLT|C_XYZE|C_PRIM|C_GAMMA|C_CXFM); |
511 |
< |
cvts.capdate[0] = '\0'; |
512 |
< |
cvts.owner[0] = '\0'; |
502 |
< |
cvts.stonits = 1.; |
503 |
< |
cvts.pixrat = 1.; |
504 |
< |
cvts.pconf = PLANARCONFIG_CONTIG; |
505 |
< |
getheader(cvts.rfp, headline, NULL); |
506 |
< |
if ((po = fgetresolu(&i1, &i2, cvts.rfp)) < 0) |
510 |
> |
memcpy(cvts.wpt, WLPART, sizeof(cvts.wpt)); |
511 |
> |
if (getheader(cvts.rfp, headline, &cvts) < 0 || |
512 |
> |
(po = fgetresolu(&i1, &i2, cvts.rfp)) < 0) |
513 |
|
quiterr("bad Radiance picture"); |
514 |
|
cvts.xmax = i1; cvts.ymax = i2; |
515 |
|
for (i1 = 0; i1 < 8; i1++) /* interpret orientation */ |
531 |
|
case PHOTOMETRIC_LOGLUV: |
532 |
|
SET(C_RFLT|C_TFLT); |
533 |
|
CLR(C_GRY|C_TWRD); |
534 |
< |
if (!CHK(C_XYZE)) { |
534 |
> |
if (!CHK(C_XYZE|C_SPEC)) { |
535 |
|
comprgb2xyzWBmat(cvts.cmat, |
536 |
|
CHK(C_PRIM) ? cvts.prims : stdprims); |
537 |
|
SET(C_CXFM); |
556 |
|
SET(C_GAMMA|C_GAMUT); |
557 |
|
CLR(C_GRY); |
558 |
|
setcolrgam(cvts.gamcor); |
559 |
< |
if (CHK(C_XYZE)) { |
559 |
> |
if (CHK(C_XYZE|C_SPEC)) { |
560 |
|
compxyz2rgbWBmat(cvts.cmat, |
561 |
|
CHK(C_PRIM) ? cvts.prims : stdprims); |
562 |
|
SET(C_CXFM); |
638 |
|
cvts.rfp = stdin; |
639 |
|
else if ((cvts.rfp = fopen(av[ac], "r")) == NULL) |
640 |
|
quiterr("cannot open Radiance input picture"); |
641 |
+ |
SET_FILE_BINARY(cvts.rfp); |
642 |
|
/* open TIFF file */ |
643 |
|
if ((cvts.tif = TIFFOpen(av[ac+1], "w")) == NULL) |
644 |
|
quiterr("cannot open TIFF output"); |
654 |
|
|
655 |
|
|
656 |
|
static void |
657 |
+ |
ReadRadScan(struct CONVST *cvp) |
658 |
+ |
{ |
659 |
+ |
static struct CONVST *lastcvp = NULL; |
660 |
+ |
static COLOR scomp[MAXCSAMP]; |
661 |
+ |
|
662 |
+ |
if (cvp->ncc > 3) { /* convert spectral pixels */ |
663 |
+ |
SCOLR sclr; |
664 |
+ |
SCOLOR scol; |
665 |
+ |
COLOR xyz; |
666 |
+ |
int x, n; |
667 |
+ |
if (lastcvp != cvp) { |
668 |
+ |
for (n = cvp->ncc; n--; ) |
669 |
+ |
spec_cie(scomp[n], |
670 |
+ |
cvp->wpt[0] + (cvp->wpt[3] - cvp->wpt[0])*(n+1)/cvp->ncc, |
671 |
+ |
cvp->wpt[0] + (cvp->wpt[3] - cvp->wpt[0])*n/cvp->ncc); |
672 |
+ |
lastcvp = cvp; |
673 |
+ |
} |
674 |
+ |
for (x = 0; x < cvp->xmax; x++) { |
675 |
+ |
if (getbinary(sclr, cvp->ncc+1, 1, cvp->rfp) != 1) |
676 |
+ |
goto readerr; |
677 |
+ |
scolr2scolor(scol, sclr, cvp->ncc); |
678 |
+ |
setcolor(cvp->r.colors[x], 0, 0, 0); |
679 |
+ |
for (n = cvp->ncc; n--; ) { |
680 |
+ |
copycolor(xyz, scomp[n]); |
681 |
+ |
scalecolor(xyz, scol[n]); |
682 |
+ |
addcolor(cvp->r.colors[x], xyz); |
683 |
+ |
} |
684 |
+ |
} |
685 |
+ |
return; |
686 |
+ |
} |
687 |
+ |
if (freadscan(cvp->r.colors, cvp->xmax, cvp->rfp) >= 0) |
688 |
+ |
return; |
689 |
+ |
readerr: |
690 |
+ |
quiterr("error reading Radiance picture"); |
691 |
+ |
} |
692 |
+ |
|
693 |
+ |
|
694 |
+ |
static void |
695 |
|
Luv2Color( /* read/convert/write Luv->COLOR scanline */ |
696 |
|
uint32 y |
697 |
|
) |
698 |
|
{ |
699 |
< |
register int x; |
699 |
> |
int x; |
700 |
|
|
701 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT)) |
702 |
|
quiterr("internal error 1 in Luv2Color"); |
703 |
|
|
704 |
+ |
if (cvts.pconf != PLANARCONFIG_CONTIG) |
705 |
+ |
quiterr("cannot handle separate 32-bit color planes"); |
706 |
+ |
|
707 |
|
if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
708 |
|
quiterr("error reading TIFF input"); |
709 |
|
/* also works for float RGB */ |
736 |
|
) |
737 |
|
{ |
738 |
|
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
739 |
< |
register double d; |
740 |
< |
register int x; |
739 |
> |
double d; |
740 |
> |
int x; |
741 |
|
|
742 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_TWRD|C_RFLT)) |
743 |
|
quiterr("internal error 1 in RRGGBB2Color"); |
744 |
|
|
745 |
+ |
if (cvts.pconf != PLANARCONFIG_CONTIG) |
746 |
+ |
quiterr("cannot handle separate 16-bit color planes"); |
747 |
+ |
|
748 |
|
if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
749 |
|
quiterr("error reading TIFF input"); |
750 |
|
|
779 |
|
) |
780 |
|
{ |
781 |
|
float m = pow(2., (double)cvts.bradj); |
782 |
< |
register int x; |
782 |
> |
int x; |
783 |
|
|
784 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) |
785 |
|
quiterr("internal error 1 in L2Color"); |
788 |
|
quiterr("error reading TIFF input"); |
789 |
|
/* also works for float greyscale */ |
790 |
|
for (x = cvts.xmax; x--; ) { |
791 |
< |
register float f = cvts.t.fp[x]; |
791 |
> |
float f = cvts.t.fp[x]; |
792 |
|
if (cvts.bradj) f *= m; |
793 |
|
setcolor(cvts.r.colors[x], f, f, f); |
794 |
|
} |
803 |
|
) |
804 |
|
{ |
805 |
|
COLOR ctmp; |
806 |
< |
register int x; |
806 |
> |
int x; |
807 |
|
|
808 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY)) |
809 |
|
quiterr("internal error 1 in RGB2Colr"); |
859 |
|
uint32 y |
860 |
|
) |
861 |
|
{ |
862 |
< |
register int x; |
862 |
> |
int x; |
863 |
|
|
864 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != C_GRY) |
865 |
|
quiterr("internal error 1 in Gry2Colr"); |
888 |
|
{ |
889 |
|
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
890 |
|
double m; |
891 |
< |
register double d; |
892 |
< |
register int x; |
891 |
> |
double d; |
892 |
> |
int x; |
893 |
|
|
894 |
|
if (CHK(C_TFLT|C_TWRD|C_GRY|C_RFLT) != (C_GRY|C_RFLT|C_TWRD)) |
895 |
|
quiterr("internal error 1 in GGry2Color"); |
919 |
|
{ |
920 |
|
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
921 |
|
float m = pow(2.,(double)cvts.bradj); |
922 |
< |
register int x; |
922 |
> |
int x; |
923 |
|
|
924 |
|
if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY) != (C_RFLT|C_TWRD|C_GRY)) |
925 |
|
quiterr("internal error 1 in Color2GGry"); |
926 |
|
|
927 |
< |
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
877 |
< |
quiterr("error reading Radiance picture"); |
927 |
> |
ReadRadScan(&cvts); |
928 |
|
|
929 |
|
for (x = cvts.xmax; x--; ) { |
930 |
< |
register float f = m*( CHK(C_XYZE) ? |
930 |
> |
float f = m*( CHK(C_XYZE) ? |
931 |
|
colval(cvts.r.colors[x],CIEY) |
932 |
|
: bright(cvts.r.colors[x]) ); |
933 |
|
if (f <= 0) |
952 |
|
) |
953 |
|
{ |
954 |
|
float m = pow(2.,(double)cvts.bradj); |
955 |
< |
register int x; |
955 |
> |
int x; |
956 |
|
|
957 |
|
if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) |
958 |
|
quiterr("internal error 1 in Color2L"); |
959 |
|
|
960 |
< |
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
911 |
< |
quiterr("error reading Radiance picture"); |
960 |
> |
ReadRadScan(&cvts); |
961 |
|
|
962 |
|
for (x = cvts.xmax; x--; ) |
963 |
|
cvts.t.fp[x] = m*( CHK(C_XYZE) ? colval(cvts.r.colors[x],CIEY) |
973 |
|
uint32 y |
974 |
|
) |
975 |
|
{ |
976 |
< |
register int x; |
976 |
> |
int x; |
977 |
|
|
978 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT)) |
979 |
|
quiterr("internal error 1 in Color2Luv"); |
980 |
|
|
981 |
< |
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
933 |
< |
quiterr("error reading Radiance picture"); |
981 |
> |
ReadRadScan(&cvts); |
982 |
|
|
983 |
|
if (CHK(C_CXFM)) |
984 |
|
for (x = cvts.xmax; x--; ) |
1008 |
|
{ |
1009 |
|
int dogamma = (cvts.gamcor < 0.99) | (cvts.gamcor > 1.01); |
1010 |
|
float m = pow(2.,(double)cvts.bradj); |
1011 |
< |
register int x, i; |
1011 |
> |
int x, i; |
1012 |
|
|
1013 |
|
if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY) != (C_RFLT|C_TWRD)) |
1014 |
|
quiterr("internal error 1 in Color2RRGGBB"); |
1015 |
|
|
1016 |
< |
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
969 |
< |
quiterr("error reading Radiance picture"); |
1016 |
> |
ReadRadScan(&cvts); |
1017 |
|
|
1018 |
|
for (x = cvts.xmax; x--; ) { |
1019 |
|
if (CHK(C_CXFM)) { |
1020 |
|
colortrans(cvts.r.colors[x], cvts.cmat, |
1021 |
|
cvts.r.colors[x]); |
1022 |
|
if (CHK(C_GAMUT)) |
1023 |
< |
clipgamut(cvts.r.colors[x], cvts.t.fp[3*x + 1], |
1023 |
> |
clipgamut(cvts.r.colors[x], bright(cvts.r.colors[x]), |
1024 |
|
CGAMUT_LOWER, cblack, cwhite); |
1025 |
|
} |
1026 |
|
for (i = 3; i--; ) { |
1027 |
< |
register float f = m*colval(cvts.r.colors[x],i); |
1027 |
> |
float f = m*colval(cvts.r.colors[x],i); |
1028 |
|
if (f <= 0) |
1029 |
|
cvts.t.wp[3*x + i] = 0; |
1030 |
|
else if (f >= 1) |
1047 |
|
uint32 y |
1048 |
|
) |
1049 |
|
{ |
1050 |
< |
register int x; |
1050 |
> |
int x; |
1051 |
|
|
1052 |
|
if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != C_GRY) |
1053 |
|
quiterr("internal error 1 in Colr2Gry"); |
1054 |
|
|
1055 |
< |
if (freadcolrs(cvts.r.colrs, cvts.xmax, cvts.rfp) < 0) |
1055 |
> |
if (fread2colrs(cvts.r.colrs, cvts.xmax, cvts.rfp, |
1056 |
> |
cvts.ncc, cvts.wpt) < 0) |
1057 |
|
quiterr("error reading Radiance picture"); |
1058 |
|
|
1059 |
|
if (cvts.bradj) |
1076 |
|
) |
1077 |
|
{ |
1078 |
|
COLOR ctmp; |
1079 |
< |
register int x; |
1079 |
> |
int x; |
1080 |
|
|
1081 |
|
if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY)) |
1082 |
|
quiterr("internal error 1 in Colr2RGB"); |
1083 |
|
|
1084 |
< |
if (freadcolrs(cvts.r.colrs, cvts.xmax, cvts.rfp) < 0) |
1084 |
> |
if (fread2colrs(cvts.r.colrs, cvts.xmax, cvts.rfp, |
1085 |
> |
cvts.ncc, cvts.wpt) < 0) |
1086 |
|
quiterr("error reading Radiance picture"); |
1087 |
|
|
1088 |
|
if (cvts.bradj) |