--- ray/src/px/ra_xyze.c 1995/10/25 15:13:38 2.2 +++ ray/src/px/ra_xyze.c 1998/10/27 09:08:27 2.5 @@ -1,7 +1,7 @@ -/* Copyright (c) 1995 Regents of the University of California */ +/* Copyright (c) 1997 Silicon Graphics, Inc. */ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static char SCCSid[] = "$SunId$ SGI"; #endif /* @@ -34,6 +34,7 @@ int doflat = -1; /* produce flat file? */ char *progname; +int headline(s) /* process header line */ char *s; { @@ -46,14 +47,14 @@ char *s; rgbinp = 0; else rgbinp = -2; - return; /* don't echo */ + return(0); /* don't echo */ } if (isprims(s)) { /* get input primaries */ primsval(inprims, s); - return; /* don't echo */ + return(0); /* don't echo */ } /* should I grok colcorr also? */ - fputs(s, stdout); + return(fputs(s, stdout)); } @@ -125,8 +126,6 @@ char *argv[]; if (rgbinp == -1) rgbinp = !rgbout; printargs(argc, argv, stdout); /* add to header */ - if (expcomp < 0.99 || expcomp > 1.01) - fputexpos(expcomp, stdout); convert(); /* convert picture */ exit(0); userr: @@ -154,37 +153,36 @@ convert() /* convert to XYZE or RGBE picture */ COLORMAT xfm; register COLOR *scanin; register COLR *scanout; + double ourexp = expcomp; int y; register int x; /* compute transform */ if (rgbout) { - double mult; if (rgbinp) { /* RGBE -> RGBE */ comprgb2rgbmat(xfm, inprims, outprims); - mult = expcomp; } else { /* XYZE -> RGBE */ compxyz2rgbmat(xfm, outprims); - mult = expcomp/WHTEFFICACY; + ourexp *= WHTEFFICACY; } - for (y = 0; y < 3; y++) - for (x = 0; x < 3; x++) - xfm[y][x] *= mult; } else { if (rgbinp) { /* RGBE -> XYZE */ comprgb2xyzmat(xfm, inprims); - for (y = 0; y < 3; y++) - for (x = 0; x < 3; x++) - xfm[y][x] *= WHTEFFICACY*expcomp; + ourexp /= WHTEFFICACY; } else { /* XYZE -> XYZE */ for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) - xfm[y][x] = x==y ? expcomp : 0.; + xfm[y][x] = x==y ? 1. : 0.; } } + for (y = 0; y < 3; y++) + for (x = 0; x < 3; x++) + xfm[y][x] *= expcomp; /* get input resolution */ if ((order = fgetresolu(&xmax, &ymax, stdin)) < 0) quiterr("bad picture format"); /* complete output header */ + if (ourexp < 0.99 || ourexp > 1.01) + fputexpos(ourexp, stdout); if (rgbout) { fputprims(outprims, stdout); fputformat(COLRFMT, stdout); @@ -201,8 +199,12 @@ convert() /* convert to XYZE or RGBE picture */ for (y = 0; y < ymax; y++) { if (freadscan(scanin, xmax, stdin) < 0) quiterr("error reading input picture"); - for (x = 0; x < xmax; x++) + for (x = 0; x < xmax; x++) { colortrans(scanin[x], xfm, scanin[x]); + if (rgbout) + clipgamut(scanin[x], bright(scanin[x]), + CGAMUT_LOWER, cblack, cwhite); + } if (scanout != NULL) { for (x = 0; x < xmax; x++) setcolr(scanout[x], colval(scanin[x],RED),