--- ray/src/util/rmatrix.c 2019/08/14 18:20:02 2.35 +++ ray/src/util/rmatrix.c 2020/03/25 01:51:09 2.40 @@ -1,14 +1,11 @@ #ifndef lint -static const char RCSid[] = "$Id: rmatrix.c,v 2.35 2019/08/14 18:20:02 greg Exp $"; +static const char RCSid[] = "$Id: rmatrix.c,v 2.40 2020/03/25 01:51:09 greg Exp $"; #endif /* * General matrix operations. */ -#include #include -#include -#include #include #include "rtio.h" #include "platform.h" @@ -32,6 +29,7 @@ rmx_alloc(int nr, int nc, int n) return(NULL); dnew->nrows = nr; dnew->ncols = nc; dnew->ncomp = n; dnew->dtype = DTdouble; + dnew->swapin = 0; dnew->info = NULL; return(dnew); } @@ -102,6 +100,17 @@ get_dminfo(char *s, void *p) ip->swapin = (nativebigendian() != i); return(0); } + if (isexpos(s)) { + double d = exposval(s); + scalecolor(ip->mtx, d); + return(0); + } + if (iscolcor(s)) { + COLOR ctmp; + colcorval(ctmp, s); + multcolor(ip->mtx, ctmp); + return(0); + } if (!formatval(fmt, s)) { rmx_addinfo(ip, s); return(0); @@ -201,7 +210,7 @@ rmx_load(const char *inspec) } else if (inspec[0] == '!') { if (!(fp = popen(inspec+1, "r"))) return(NULL); - SET_FILE_BINARY(stdin); + SET_FILE_BINARY(fp); } else { const char *sp = inspec; /* check suffix */ while (*sp) @@ -228,6 +237,7 @@ rmx_load(const char *inspec) dinfo.dtype = DTascii; /* assumed w/o FORMAT */ dinfo.swapin = 0; dinfo.info = NULL; + dinfo.mtx[0] = dinfo.mtx[1] = dinfo.mtx[2] = 1.; if (getheader(fp, get_dminfo, &dinfo) < 0) { fclose(fp); return(NULL); @@ -253,7 +263,7 @@ rmx_load(const char *inspec) dnew->info = dinfo.info; switch (dinfo.dtype) { case DTascii: - SET_FILE_TEXT(stdin); + SET_FILE_TEXT(fp); if (!rmx_load_ascii(dnew, fp)) goto loaderr; dnew->dtype = DTascii; /* should leave double? */ @@ -274,7 +284,14 @@ rmx_load(const char *inspec) case DTxyze: if (!rmx_load_rgbe(dnew, fp)) goto loaderr; - dnew->dtype = dinfo.dtype; + dnew->dtype = dinfo.dtype; /* undo exposure? */ + if ((dinfo.mtx[0] != 1.) | (dinfo.mtx[1] != 1.) | + (dinfo.mtx[2] != 1.)) { + dinfo.mtx[0] = 1./dinfo.mtx[0]; + dinfo.mtx[1] = 1./dinfo.mtx[1]; + dinfo.mtx[2] = 1./dinfo.mtx[2]; + rmx_scale(dnew, dinfo.mtx); + } break; default: goto loaderr; @@ -654,7 +671,7 @@ rmx_transform(const RMATRIX *msrc, int n, const double return(NULL); if (msrc->info) { char buf[128]; - sprintf(buf, "Applied %dx%d matrix transform\n", + sprintf(buf, "Applied %dx%d component transform\n", dnew->ncomp, msrc->ncomp); rmx_addinfo(dnew, msrc->info); rmx_addinfo(dnew, buf);