--- ray/src/px/ra_tiff.c 1997/07/24 11:47:05 2.9 +++ ray/src/px/ra_tiff.c 2003/02/22 02:07:28 2.20 @@ -1,25 +1,21 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: ra_tiff.c,v 2.20 2003/02/22 02:07:28 greg Exp $"; #endif - /* * Program to convert between RADIANCE and TIFF files. - * Added experimental LogLuv encodings 7/97 (GWL). + * Added LogLuv encodings 7/97 (GWL). + * Added white-balance adjustment 10/01 (GW). */ #include #include +#include #include "tiffio.h" #include "color.h" #include "resolu.h" #define GAMCOR 2.2 /* default gamma */ -#ifndef malloc -extern char *malloc(); -#endif /* conversion flags */ #define C_CXFM 0x1 /* needs color transformation */ #define C_GAMUT 0x2 /* needs gamut mapping */ @@ -28,16 +24,18 @@ extern char *malloc(); #define C_XYZE 0x10 /* Radiance is XYZE */ #define C_RFLT 0x20 /* Radiance data is float */ #define C_TFLT 0x40 /* TIFF data is float */ -#define C_PRIM 0x80 /* has assigned primaries */ +#define C_TWRD 0x80 /* TIFF data is 16-bit */ +#define C_PRIM 0x100 /* has assigned primaries */ struct { uint16 flags; /* conversion flags (defined above) */ uint16 comp; /* TIFF compression type */ + uint16 phot; /* TIFF photometric type */ uint16 pconf; /* TIFF planar configuration */ float gamcor; /* gamma correction value */ short bradj; /* Radiance exposure adjustment (stops) */ uint16 orient; /* visual orientation (TIFF spec.) */ - float stonits; /* input conversion to nits */ + double stonits; /* input conversion to nits */ float pixrat; /* pixel aspect ratio */ FILE *rfp; /* Radiance stream pointer */ TIFF *tif; /* TIFF pointer */ @@ -51,12 +49,14 @@ struct { } r; /* Radiance scanline */ union { uint8 *bp; /* byte pointer */ + uint16 *wp; /* word pointer */ float *fp; /* float pointer */ char *p; /* generic pointer */ } t; /* TIFF scanline */ int (*tf)(); /* translation procedure */ } cvts = { /* conversion structure */ - 0, COMPRESSION_NONE, PLANARCONFIG_CONTIG, GAMCOR, 0, + 0, COMPRESSION_NONE, PHOTOMETRIC_RGB, + PLANARCONFIG_CONTIG, GAMCOR, 0, 1, 1., 1., }; #define CHK(f) (cvts.flags & (f)) @@ -66,6 +66,7 @@ struct { int Luv2Color(), L2Color(), RGB2Colr(), Gry2Colr(); int Color2Luv(), Color2L(), Colr2RGB(), Colr2Gry(); +int RRGGBB2Color(), GGry2Color(); short ortab[8] = { /* orientation conversion table */ YMAJOR|YDECR, @@ -105,10 +106,12 @@ char *argv[]; cvts.comp = COMPRESSION_LZW; break; case 'L': /* LogLuv 32-bit output */ - cvts.comp = COMPRESSION_LOGLUV32; + cvts.comp = COMPRESSION_SGILOG; + cvts.phot = PHOTOMETRIC_LOGLUV; break; case 'l': /* LogLuv 24-bit output */ - cvts.comp = COMPRESSION_LOGLUV24; + cvts.comp = COMPRESSION_SGILOG24; + cvts.phot = PHOTOMETRIC_LOGLUV; break; case 'b': /* greyscale output? */ TGL(C_GRY); @@ -141,9 +144,13 @@ doneopts: if (i != argc-2) goto userr; - if (CHK(C_GRY) && (cvts.comp == COMPRESSION_LOGLUV24 || - cvts.comp == COMPRESSION_LOGLUV32)) - cvts.comp = COMPRESSION_LOGL16; + if (CHK(C_GRY)) /* consistency corrections */ + if (cvts.phot == PHOTOMETRIC_RGB) + cvts.phot = PHOTOMETRIC_MINISBLACK; + else { + cvts.phot = PHOTOMETRIC_LOGL; + cvts.comp = COMPRESSION_SGILOG; + } ra2tiff(i, argv); } @@ -176,7 +183,8 @@ allocbufs() /* allocate scanline buffers */ int rsiz, tsiz; rsiz = CHK(C_RFLT) ? sizeof(COLOR) : sizeof(COLR); - tsiz = (CHK(C_TFLT) ? sizeof(float) : sizeof(uint8)) * + tsiz = (CHK(C_TFLT) ? sizeof(float) : + CHK(C_TWRD) ? sizeof(uint16) : sizeof(uint8)) * (CHK(C_GRY) ? 1 : 3); cvts.r.p = (char *)malloc(rsiz*cvts.xmax); cvts.t.p = (char *)malloc(tsiz*cvts.xmax); @@ -216,65 +224,85 @@ initfromtif() /* initialize conversion from TIFF inpu if (TIFFGetField(cvts.tif, TIFFTAG_XRESOLUTION, &f1) && TIFFGetField(cvts.tif, TIFFTAG_YRESOLUTION, &f2)) cvts.pixrat = f1/f2; - else - cvts.pixrat = 1.; - if (!TIFFGetFieldDefaulted(cvts.tif, TIFFTAG_ORIENTATION, &cvts.orient)) - cvts.orient = 1; + TIFFGetFieldDefaulted(cvts.tif, TIFFTAG_ORIENTATION, &cvts.orient); - switch (cvts.comp) { - case COMPRESSION_LOGL16: - SET(C_GRY|C_RFLT|C_TFLT|C_GAMUT); - cvts.pconf = PLANARCONFIG_CONTIG; - TIFFSetField(cvts.tif, TIFFTAG_LOGLUVDATAFMT, - LOGLUVDATAFMT_FLTY); - TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, - SAMPLEFORMAT_IEEEFP); - cvts.tf = L2Color; - break; - case COMPRESSION_LOGLUV24: - case COMPRESSION_LOGLUV32: + if (!TIFFGetFieldDefaulted(cvts.tif, TIFFTAG_PHOTOMETRIC, &cvts.phot)) + quiterr("TIFF has unspecified photometric type"); + + switch (cvts.phot) { + case PHOTOMETRIC_LOGLUV: SET(C_RFLT|C_TFLT); if (!CHK(C_XYZE)) { cpcolormat(cvts.cmat, xyz2rgbmat); SET(C_CXFM|C_GAMUT); - } else if (cvts.comp == COMPRESSION_LOGLUV32) + } else if (cvts.comp == COMPRESSION_SGILOG) SET(C_GAMUT); if (cvts.pconf != PLANARCONFIG_CONTIG) quiterr("cannot handle separate Luv planes"); - TIFFSetField(cvts.tif, TIFFTAG_LOGLUVDATAFMT, - LOGLUVDATAFMT_FLTXYZ); - TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, - SAMPLEFORMAT_IEEEFP); + TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, + SGILOGDATAFMT_FLOAT); cvts.tf = Luv2Color; break; - default: - SET(C_GAMMA|C_GAMUT); + case PHOTOMETRIC_LOGL: + SET(C_GRY|C_RFLT|C_TFLT|C_GAMUT); + cvts.pconf = PLANARCONFIG_CONTIG; + TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, + SGILOGDATAFMT_FLOAT); + cvts.tf = L2Color; + break; + case PHOTOMETRIC_YCBCR: + if (cvts.comp == COMPRESSION_JPEG && + cvts.pconf == PLANARCONFIG_CONTIG) { + TIFFSetField(cvts.tif, TIFFTAG_JPEGCOLORMODE, + JPEGCOLORMODE_RGB); + cvts.phot = PHOTOMETRIC_RGB; + } else + quiterr("unsupported photometric type"); + /* fall through */ + case PHOTOMETRIC_RGB: + SET(C_GAMMA); setcolrgam(cvts.gamcor); if (CHK(C_XYZE)) { - comprgb2xyzmat(cvts.cmat, + comprgb2xyzWBmat(cvts.cmat, CHK(C_PRIM) ? cvts.prims : stdprims); SET(C_CXFM); } if (!TIFFGetField(cvts.tif, TIFFTAG_SAMPLESPERPIXEL, &hi) || - (hi != 1 && hi != 3)) - quiterr("unsupported samples per pixel"); - if (hi == 1) { - SET(C_GRY); - cvts.pconf = PLANARCONFIG_CONTIG; - cvts.tf = Gry2Colr; - } else + hi != 3) + quiterr("unsupported samples per pixel for RGB"); + if (!TIFFGetField(cvts.tif, TIFFTAG_BITSPERSAMPLE, &hi) || + hi != 8 & hi != 16) + quiterr("unsupported bits per sample for RGB"); + if (hi == 8) cvts.tf = RGB2Colr; + else { + cvts.tf = RRGGBB2Color; + SET(C_RFLT|C_TWRD); + } + break; + case PHOTOMETRIC_MINISBLACK: + SET(C_GRY|C_GAMMA); + setcolrgam(cvts.gamcor); + cvts.pconf = PLANARCONFIG_CONTIG; + if (!TIFFGetField(cvts.tif, TIFFTAG_SAMPLESPERPIXEL, &hi) || + hi != 1) + quiterr("unsupported samples per pixel for greyscale"); if (!TIFFGetField(cvts.tif, TIFFTAG_BITSPERSAMPLE, &hi) || - hi != 8) - quiterr("unsupported bits per sample"); + hi != 8 & hi != 16) + quiterr("unsupported bits per sample for greyscale"); + if (hi == 8) + cvts.tf = Gry2Colr; + else { + cvts.tf = GGry2Color; + SET(C_RFLT|C_TWRD); + } break; + default: + quiterr("unsupported photometric type"); + break; } - if (TIFFGetField(cvts.tif, TIFFTAG_PHOTOMETRIC, &hi) && - hi != (CHK(C_GRY) ? PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB)) - quiterr("unsupported photometric interpretation"); - if (!TIFFGetField(cvts.tif, TIFFTAG_IMAGEWIDTH, &cvts.xmax) || !TIFFGetField(cvts.tif, TIFFTAG_IMAGELENGTH, &cvts.ymax)) quiterr("unknown input image resolution"); @@ -342,21 +370,22 @@ char *s; SET(C_XYZE); else quiterr("unrecognized input picture format"); - return; + return(1); } if (isexpos(s)) { cvts.stonits /= exposval(s); - return; + return(1); } if (isaspect(s)) { cvts.pixrat *= aspectval(s); - return; + return(1); } if (isprims(s)) { primsval(cvts.prims, s); SET(C_PRIM); - return; + return(1); } + return(0); } @@ -385,57 +414,63 @@ initfromrad() /* initialize input from a Radiance pi cvts.stonits *= WHTEFFICACY; /* set up conversion */ TIFFSetField(cvts.tif, TIFFTAG_COMPRESSION, cvts.comp); + TIFFSetField(cvts.tif, TIFFTAG_PHOTOMETRIC, cvts.phot); - switch (cvts.comp) { - case COMPRESSION_LOGL16: - SET(C_GRY|C_RFLT|C_TFLT); - TIFFSetField(cvts.tif, TIFFTAG_LOGLUVDATAFMT, - LOGLUVDATAFMT_FLTY); - TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, - SAMPLEFORMAT_IEEEFP); - cvts.tf = Color2L; - break; - case COMPRESSION_LOGLUV24: - case COMPRESSION_LOGLUV32: + switch (cvts.phot) { + case PHOTOMETRIC_LOGLUV: SET(C_RFLT|C_TFLT); CLR(C_GRY); if (!CHK(C_XYZE)) { - cpcolormat(cvts.cmat, rgb2xyzmat); + comprgb2xyzWBmat(cvts.cmat, + CHK(C_PRIM) ? cvts.prims : stdprims); SET(C_CXFM); } - TIFFSetField(cvts.tif, TIFFTAG_LOGLUVDATAFMT, - LOGLUVDATAFMT_FLTXYZ); - TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT, - SAMPLEFORMAT_IEEEFP); + if (cvts.comp != COMPRESSION_SGILOG && + cvts.comp != COMPRESSION_SGILOG24) + quiterr("internal error 2 in initfromrad"); + TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, + SGILOGDATAFMT_FLOAT); cvts.tf = Color2Luv; break; - default: + case PHOTOMETRIC_LOGL: + SET(C_GRY|C_RFLT|C_TFLT); + if (cvts.comp != COMPRESSION_SGILOG) + quiterr("internal error 3 in initfromrad"); + TIFFSetField(cvts.tif, TIFFTAG_SGILOGDATAFMT, + SGILOGDATAFMT_FLOAT); + cvts.tf = Color2L; + break; + case PHOTOMETRIC_RGB: SET(C_GAMMA|C_GAMUT); + CLR(C_GRY); setcolrgam(cvts.gamcor); if (CHK(C_XYZE)) { - compxyz2rgbmat(cvts.cmat, + compxyz2rgbWBmat(cvts.cmat, CHK(C_PRIM) ? cvts.prims : stdprims); SET(C_CXFM); } - if (CHK(C_GRY)) - cvts.tf = Colr2Gry; - else - cvts.tf = Colr2RGB; if (CHK(C_PRIM)) { TIFFSetField(cvts.tif, TIFFTAG_PRIMARYCHROMATICITIES, (float *)cvts.prims); TIFFSetField(cvts.tif, TIFFTAG_WHITEPOINT, (float *)cvts.prims[WHT]); } + cvts.tf = Colr2RGB; break; + case PHOTOMETRIC_MINISBLACK: + SET(C_GRY|C_GAMMA|C_GAMUT); + setcolrgam(cvts.gamcor); + cvts.tf = Colr2Gry; + break; + default: + quiterr("internal error 4 in initfromrad"); + break; } /* set other TIFF fields */ TIFFSetField(cvts.tif, TIFFTAG_IMAGEWIDTH, cvts.xmax); TIFFSetField(cvts.tif, TIFFTAG_IMAGELENGTH, cvts.ymax); TIFFSetField(cvts.tif, TIFFTAG_SAMPLESPERPIXEL, CHK(C_GRY) ? 1 : 3); TIFFSetField(cvts.tif, TIFFTAG_BITSPERSAMPLE, CHK(C_TFLT) ? 32 : 8); - TIFFSetField(cvts.tif, TIFFTAG_PHOTOMETRIC, - CHK(C_GRY) ? PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB); TIFFSetField(cvts.tif, TIFFTAG_XRESOLUTION, 72.); TIFFSetField(cvts.tif, TIFFTAG_YRESOLUTION, 72./cvts.pixrat); TIFFSetField(cvts.tif, TIFFTAG_ORIENTATION, cvts.orient); @@ -443,7 +478,10 @@ initfromrad() /* initialize input from a Radiance pi TIFFSetField(cvts.tif, TIFFTAG_PLANARCONFIG, cvts.pconf); TIFFSetField(cvts.tif, TIFFTAG_STONITS, cvts.stonits/pow(2.,(double)cvts.bradj)); - i1 = TIFFScanlineSize(cvts.tif); + if (cvts.comp == COMPRESSION_NONE) + i1 = TIFFScanlineSize(cvts.tif); + else + i1 = 3*cvts.xmax; /* conservative guess */ i2 = 8192/i1; /* compute good strip size */ if (i2 < 1) i2 = 1; TIFFSetField(cvts.tif, TIFFTAG_ROWSPERSTRIP, (uint32)i2); @@ -482,16 +520,16 @@ uint32 y; { register int x; - if (CHK(C_RFLT|C_TFLT) != (C_RFLT|C_TFLT) | CHK(C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT)) quiterr("internal error 1 in Luv2Color"); if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) quiterr("error reading TIFF input"); for (x = cvts.xmax; x--; ) { - cvts.r.colors[x][RED] = cvts.t.fp[3*x]; - cvts.r.colors[x][GRN] = cvts.t.fp[3*x + 1]; - cvts.r.colors[x][BLU] = cvts.t.fp[3*x + 2]; + colval(cvts.r.colors[x],CIEX) = cvts.t.fp[3*x]; + colval(cvts.r.colors[x],CIEY) = cvts.t.fp[3*x + 1]; + colval(cvts.r.colors[x],CIEZ) = cvts.t.fp[3*x + 2]; if (CHK(C_CXFM)) colortrans(cvts.r.colors[x], cvts.cmat, cvts.r.colors[x]); @@ -511,21 +549,64 @@ uint32 y; int +RRGGBB2Color(y) /* read/convert/write RGB16->COLOR scanline */ +uint32 y; +{ + int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; + register double d; + register int x; + + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_TWRD|C_RFLT)) + quiterr("internal error 1 in RRGGBB2Color"); + + if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) + quiterr("error reading TIFF input"); + + for (x = cvts.xmax; x--; ) { + d = (cvts.t.wp[3*x] + 0.5)*(1./(1L<<16)); + if (dogamma) d = pow(d, cvts.gamcor); + colval(cvts.r.colors[x],RED) = d; + d = (cvts.t.wp[3*x + 1] + 0.5)*(1./(1L<<16)); + if (dogamma) d = pow(d, cvts.gamcor); + colval(cvts.r.colors[x],GRN) = d; + d = (cvts.t.wp[3*x + 2] + 0.5)*(1./(1L<<16)); + if (dogamma) d = pow(d, cvts.gamcor); + colval(cvts.r.colors[x],BLU) = d; + if (CHK(C_CXFM)) + colortrans(cvts.r.colors[x], cvts.cmat, + cvts.r.colors[x]); + if (CHK(C_GAMUT)) + clipgamut(cvts.r.colors[x], cvts.t.fp[3*x + 1], + CGAMUT_LOWER, cblack, cwhite); + } + if (cvts.bradj) { + d = pow(2.,(double)cvts.bradj); + for (x = cvts.xmax; x--; ) + scalecolor(cvts.r.colors[x], d); + } + + if (fwritescan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) + quiterr("error writing Radiance picture"); +} + + +int L2Color(y) /* read/convert/write L16->COLOR scanline */ uint32 y; { register int x; - if (CHK(C_RFLT|C_TFLT|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) quiterr("internal error 1 in L2Color"); if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) quiterr("error reading TIFF input"); for (x = cvts.xmax; x--; ) - cvts.r.colors[x][RED] = - cvts.r.colors[x][GRN] = - cvts.r.colors[x][BLU] = cvts.t.fp[x] > 0. ? cvts.t.fp[x] : 0.; + colval(cvts.r.colors[x],RED) = + colval(cvts.r.colors[x],GRN) = + colval(cvts.r.colors[x],BLU) = + cvts.t.fp[x] > 0. ? cvts.t.fp[x] : 0.; if (fwritescan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) quiterr("error writing Radiance picture"); @@ -539,7 +620,7 @@ uint32 y; COLOR ctmp; register int x; - if (CHK(C_RFLT|C_TFLT|C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY)) quiterr("internal error 1 in RGB2Colr"); if (cvts.pconf == PLANARCONFIG_CONTIG) { @@ -554,10 +635,10 @@ uint32 y; if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) goto readerr; if (TIFFReadScanline(cvts.tif, - (tidata_t)(cvts.t.bp + cvts.xmax), y, 1) < 0) + (tdata_t)(cvts.t.bp + cvts.xmax), y, 1) < 0) goto readerr; if (TIFFReadScanline(cvts.tif, - (tidata_t)(cvts.t.bp + 2*cvts.xmax), y, 2) < 0) + (tdata_t)(cvts.t.bp + 2*cvts.xmax), y, 2) < 0) goto readerr; for (x = cvts.xmax; x--; ) { cvts.r.colrs[x][RED] = cvts.t.bp[x]; @@ -594,7 +675,7 @@ uint32 y; { register int x; - if (CHK(C_RFLT|C_TFLT) | !CHK(C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != C_GRY) quiterr("internal error 1 in Gry2Colr"); if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) @@ -615,13 +696,43 @@ uint32 y; int +GGry2Color(y) /* read/convert/write G16->COLOR scanline */ +uint32 y; +{ + int dogamma = cvts.gamcor < 0.99 | cvts.gamcor > 1.01; + double m; + register double d; + register int x; + + if (CHK(C_TFLT|C_TWRD|C_GRY|C_RFLT) != (C_GRY|C_RFLT|C_TWRD)) + quiterr("internal error 1 in GGry2Color"); + + if (TIFFReadScanline(cvts.tif, cvts.t.p, y, 0) < 0) + quiterr("error reading TIFF input"); + + if (cvts.bradj) + m = pow(2., (double)cvts.bradj); + for (x = cvts.xmax; x--; ) { + d = (cvts.t.wp[x] + 0.5)*(1./(1L<<16)); + if (dogamma) d = pow(d, cvts.gamcor); + if (cvts.bradj) d *= m; + colval(cvts.r.colors[x],RED) = + colval(cvts.r.colors[x],GRN) = + colval(cvts.r.colors[x],BLU) = d; + } + if (fwritescan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) + quiterr("error writing Radiance picture"); +} + + +int Color2L(y) /* read/convert/write COLOR->L16 scanline */ uint32 y; { double m = pow(2.,(double)cvts.bradj); register int x; - if (CHK(C_RFLT|C_TFLT) != (C_RFLT|C_TFLT) | !CHK(C_GRY)) + if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY) != (C_RFLT|C_TFLT|C_GRY)) quiterr("internal error 1 in Color2L"); if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) @@ -642,7 +753,7 @@ uint32 y; { register int x; - if (CHK(C_RFLT|C_TFLT) != (C_RFLT|C_TFLT) | CHK(C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != (C_RFLT|C_TFLT)) quiterr("internal error 1 in Color2Luv"); if (freadscan(cvts.r.colors, cvts.xmax, cvts.rfp) < 0) @@ -659,9 +770,9 @@ uint32 y; } for (x = cvts.xmax; x--; ) { - cvts.t.fp[3*x] = colval(cvts.r.colors[x],RED); - cvts.t.fp[3*x+1] = colval(cvts.r.colors[x],GRN); - cvts.t.fp[3*x+2] = colval(cvts.r.colors[x],BLU); + cvts.t.fp[3*x] = colval(cvts.r.colors[x],CIEX); + cvts.t.fp[3*x+1] = colval(cvts.r.colors[x],CIEY); + cvts.t.fp[3*x+2] = colval(cvts.r.colors[x],CIEZ); } if (TIFFWriteScanline(cvts.tif, cvts.t.p, y, 0) < 0) @@ -675,7 +786,7 @@ uint32 y; { register int x; - if (CHK(C_RFLT|C_TFLT) | !CHK(C_GRY)) + if (CHK(C_RFLT|C_TWRD|C_TFLT|C_GRY) != C_GRY) quiterr("internal error 1 in Colr2Gry"); if (freadcolrs(cvts.r.colrs, cvts.xmax, cvts.rfp) < 0) @@ -702,7 +813,7 @@ uint32 y; COLOR ctmp; register int x; - if (CHK(C_RFLT|C_TFLT|C_GRY)) + if (CHK(C_RFLT|C_TFLT|C_TWRD|C_GRY)) quiterr("internal error 1 in Colr2RGB"); if (freadcolrs(cvts.r.colrs, cvts.xmax, cvts.rfp) < 0)