--- ray/src/px/ra_bmp.c 2018/08/02 18:33:46 2.12 +++ ray/src/px/ra_bmp.c 2024/09/10 20:24:42 2.15 @@ -1,14 +1,13 @@ #ifndef lint -static const char RCSid[] = "$Id: ra_bmp.c,v 2.12 2018/08/02 18:33:46 greg Exp $"; +static const char RCSid[] = "$Id: ra_bmp.c,v 2.15 2024/09/10 20:24:42 greg Exp $"; #endif /* * program to convert between RADIANCE and Windows BMP file */ -#include #include -#include +#include "rtio.h" #include "platform.h" #include "color.h" #include "tonemap.h" @@ -220,6 +219,8 @@ headline(char *s, void *p) rgbinp = TM_XYZPRIM; return(0); } + if (!strcmp(fmt,SPECFMT)) + return(0); return(-1); } if (isprims(s)) { /* get input primaries */ @@ -227,6 +228,14 @@ headline(char *s, void *p) rgbinp = myinprims; return(0); } + if (isncomp(s)) { + NCSAMP = ncompval(s); + return(0); + } + if (iswlsplit(s)) { + wlsplitval(WLPART, s); + return(0); + } /* should I grok colcorr also? */ return(0); } @@ -250,11 +259,12 @@ rad2bmp(FILE *rfp, BMPWriter *bwr, int inv, RGBPRIMP m usexfm = (monpri != NULL ? rgbinp != monpri : rgbinp != TM_XYZPRIM && rgbinp != stdprims); if (usexfm) { - double expcomp = pow(2.0, (double)bradj); + RGBPRIMP destpri = monpri != NULL ? monpri : stdprims; + double expcomp = pow(2.0, (double)bradj); if (rgbinp == TM_XYZPRIM) - compxyz2rgbWBmat(xfm, monpri); + compxyz2rgbWBmat(xfm, destpri); else - comprgb2rgbWBmat(xfm, rgbinp, monpri); + comprgb2rgbWBmat(xfm, rgbinp, destpri); for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) xfm[y][x] *= expcomp; @@ -269,7 +279,7 @@ rad2bmp(FILE *rfp, BMPWriter *bwr, int inv, RGBPRIMP m } /* convert each scanline */ for ( ; y != yend; y += ystp) { - if (freadcolrs(scanin, bwr->hdr->width, rfp) < 0) + if (fread2colrs(scanin, bwr->hdr->width, rfp, NCSAMP, WLPART) < 0) quiterr("error reading Radiance picture"); if (usexfm) for (x = bwr->hdr->width; x--; ) {