38 |
|
float gamcor; /* gamma correction value */ |
39 |
|
short bradj; /* Radiance exposure adjustment (stops) */ |
40 |
|
uint16 orient; /* visual orientation (TIFF spec.) */ |
41 |
< |
float stonits; /* input conversion to nits */ |
41 |
> |
double stonits; /* input conversion to nits */ |
42 |
|
float pixrat; /* pixel aspect ratio */ |
43 |
|
FILE *rfp; /* Radiance stream pointer */ |
44 |
|
TIFF *tif; /* TIFF pointer */ |
241 |
|
if (cvts.pconf != PLANARCONFIG_CONTIG) |
242 |
|
quiterr("cannot handle separate Luv planes"); |
243 |
|
TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, |
244 |
< |
SGILOGDATAFMT_FLTXYZ); |
244 |
> |
SGILOGDATAFMT_FLOAT); |
245 |
|
cvts.tf = Luv2Color; |
246 |
|
break; |
247 |
|
case PHOTOMETRIC_LOGL: |
248 |
|
SET(C_GRY|C_RFLT|C_TFLT|C_GAMUT); |
249 |
|
cvts.pconf = PLANARCONFIG_CONTIG; |
250 |
|
TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, |
251 |
< |
SGILOGDATAFMT_FLTY); |
251 |
> |
SGILOGDATAFMT_FLOAT); |
252 |
|
cvts.tf = L2Color; |
253 |
|
break; |
254 |
+ |
case PHOTOMETRIC_YCBCR: |
255 |
+ |
if (cvts.comp == COMPRESSION_JPEG && |
256 |
+ |
cvts.pconf == PLANARCONFIG_CONTIG) { |
257 |
+ |
TIFFSetField(cvts.tif, TIFFTAG_JPEGCOLORMODE, |
258 |
+ |
JPEGCOLORMODE_RGB); |
259 |
+ |
cvts.phot = PHOTOMETRIC_RGB; |
260 |
+ |
} else |
261 |
+ |
quiterr("unsupported photometric type"); |
262 |
+ |
/* fall through */ |
263 |
|
case PHOTOMETRIC_RGB: |
264 |
|
SET(C_GAMMA|C_GAMUT); |
265 |
|
setcolrgam(cvts.gamcor); |
278 |
|
break; |
279 |
|
case PHOTOMETRIC_MINISBLACK: |
280 |
|
SET(C_GRY|C_GAMMA|C_GAMUT); |
281 |
+ |
setcolrgam(cvts.gamcor); |
282 |
|
cvts.pconf = PLANARCONFIG_CONTIG; |
283 |
|
if (!TIFFGetField(cvts.tif, TIFFTAG_SAMPLESPERPIXEL, &hi) || |
284 |
|
hi != 1) |
360 |
|
SET(C_XYZE); |
361 |
|
else |
362 |
|
quiterr("unrecognized input picture format"); |
363 |
< |
return; |
363 |
> |
return(1); |
364 |
|
} |
365 |
|
if (isexpos(s)) { |
366 |
|
cvts.stonits /= exposval(s); |
367 |
< |
return; |
367 |
> |
return(1); |
368 |
|
} |
369 |
|
if (isaspect(s)) { |
370 |
|
cvts.pixrat *= aspectval(s); |
371 |
< |
return; |
371 |
> |
return(1); |
372 |
|
} |
373 |
|
if (isprims(s)) { |
374 |
|
primsval(cvts.prims, s); |
375 |
|
SET(C_PRIM); |
376 |
< |
return; |
376 |
> |
return(1); |
377 |
|
} |
378 |
+ |
return(0); |
379 |
|
} |
380 |
|
|
381 |
|
|
418 |
|
cvts.comp != COMPRESSION_SGILOG24) |
419 |
|
quiterr("internal error 2 in initfromrad"); |
420 |
|
TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, |
421 |
< |
SGILOGDATAFMT_FLTXYZ); |
421 |
> |
SGILOGDATAFMT_FLOAT); |
422 |
|
cvts.tf = Color2Luv; |
423 |
|
break; |
424 |
|
case PHOTOMETRIC_LOGL: |
426 |
|
if (cvts.comp != COMPRESSION_SGILOG) |
427 |
|
quiterr("internal error 3 in initfromrad"); |
428 |
|
TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, |
429 |
< |
SGILOGDATAFMT_FLTY); |
429 |
> |
SGILOGDATAFMT_FLOAT); |
430 |
|
cvts.tf = Color2L; |
431 |
|
break; |
432 |
|
case PHOTOMETRIC_RGB: |
516 |
|
quiterr("error reading TIFF input"); |
517 |
|
|
518 |
|
for (x = cvts.xmax; x--; ) { |
519 |
< |
cvts.r.colors[x][RED] = cvts.t.fp[3*x]; |
520 |
< |
cvts.r.colors[x][GRN] = cvts.t.fp[3*x + 1]; |
521 |
< |
cvts.r.colors[x][BLU] = cvts.t.fp[3*x + 2]; |
519 |
> |
colval(cvts.r.colors[x],CIEX) = cvts.t.fp[3*x]; |
520 |
> |
colval(cvts.r.colors[x],CIEY) = cvts.t.fp[3*x + 1]; |
521 |
> |
colval(cvts.r.colors[x],CIEZ) = cvts.t.fp[3*x + 2]; |
522 |
|
if (CHK(C_CXFM)) |
523 |
|
colortrans(cvts.r.colors[x], cvts.cmat, |
524 |
|
cvts.r.colors[x]); |
550 |
|
quiterr("error reading TIFF input"); |
551 |
|
|
552 |
|
for (x = cvts.xmax; x--; ) |
553 |
< |
cvts.r.colors[x][RED] = |
554 |
< |
cvts.r.colors[x][GRN] = |
555 |
< |
cvts.r.colors[x][BLU] = cvts.t.fp[x] > 0. ? cvts.t.fp[x] : 0.; |
553 |
> |
colval(cvts.r.colors[x],RED) = |
554 |
> |
colval(cvts.r.colors[x],GRN) = |
555 |
> |
colval(cvts.r.colors[x],BLU) = |
556 |
> |
cvts.t.fp[x] > 0. ? cvts.t.fp[x] : 0.; |
557 |
|
|
558 |
|
if (fwritescan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
559 |
|
quiterr("error writing Radiance picture"); |
582 |
|
if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) |
583 |
|
goto readerr; |
584 |
|
if (TIFFReadScanline(cvts.tif, |
585 |
< |
(tidata_t)(cvts.t.bp + cvts.xmax), y, 1) < 0) |
585 |
> |
(tdata_t)(cvts.t.bp + cvts.xmax), y, 1) < 0) |
586 |
|
goto readerr; |
587 |
|
if (TIFFReadScanline(cvts.tif, |
588 |
< |
(tidata_t)(cvts.t.bp + 2*cvts.xmax), y, 2) < 0) |
588 |
> |
(tdata_t)(cvts.t.bp + 2*cvts.xmax), y, 2) < 0) |
589 |
|
goto readerr; |
590 |
|
for (x = cvts.xmax; x--; ) { |
591 |
|
cvts.r.colrs[x][RED] = cvts.t.bp[x]; |
649 |
|
double m = pow(2.,(double)cvts.bradj); |
650 |
|
register int x; |
651 |
|
|
652 |
< |
if (CHK(C_RFLT|C_TFLT) != (C_RFLT|C_TFLT) | !CHK(C_GRY)) |
652 |
> |
if (CHK(C_RFLT|C_TFLT|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) |
653 |
|
quiterr("internal error 1 in Color2L"); |
654 |
|
|
655 |
|
if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) |
687 |
|
} |
688 |
|
|
689 |
|
for (x = cvts.xmax; x--; ) { |
690 |
< |
cvts.t.fp[3*x] = colval(cvts.r.colors[x],RED); |
691 |
< |
cvts.t.fp[3*x+1] = colval(cvts.r.colors[x],GRN); |
692 |
< |
cvts.t.fp[3*x+2] = colval(cvts.r.colors[x],BLU); |
690 |
> |
cvts.t.fp[3*x] = colval(cvts.r.colors[x],CIEX); |
691 |
> |
cvts.t.fp[3*x+1] = colval(cvts.r.colors[x],CIEY); |
692 |
> |
cvts.t.fp[3*x+2] = colval(cvts.r.colors[x],CIEZ); |
693 |
|
} |
694 |
|
|
695 |
|
if (TIFFWriteScanline(cvts.tif, cvts.t.p, y, 0) < 0) |