ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/tmapcolrs.c
(Generate patch)

Comparing ray/src/common/tmapcolrs.c (file contents):
Revision 3.37 by greg, Sat Jan 15 16:57:46 2022 UTC vs.
Revision 3.38 by greg, Tue Sep 10 20:24:42 2024 UTC

# Line 142 | Line 142 | int    len
142  
143   #define FMTRGB          1       /* Input is RGBE */
144   #define FMTCIE          2       /* Input is CIE XYZE */
145 < #define FMTUNK          3       /* Input format is unspecified */
146 < #define FMTBAD          4       /* Input is not a recognized format */
145 > #define FMTSPEC         3       /* Input is N-component spectral data */
146 > #define FMTUNK          0       /* Input format is unspecified */
147 > #define FMTBAD          (-1)    /* Input is not a recognized format */
148  
149   static struct radhead {
150          int     format;         /* FMTRGB, FMTCIE, FMTUNK, FMTBAD */
151          double  expos;          /* input exposure value */
152          RGBPRIMP        primp;  /* input primaries */
153          RGBPRIMS        mypri;  /* custom primaries */
154 < } rhdefault = {FMTUNK, 1., stdprims, STDPRIMS};
154 >        int             ncs;    /* number of color samples */
155 >        float           wpt[4]; /* spectral partition */
156 > } rhdefault = {FMTUNK, 1., stdprims, STDPRIMS, 3, {0,0,0,0}};
157  
158  
159   static int
# Line 167 | Line 170 | headline(                      /* grok a header line */
170                          rh->format = FMTRGB;
171                  else if (!strcmp(fmt, CIEFMT))
172                          rh->format = FMTCIE;
173 +                else if (!strcmp(fmt, SPECFMT))
174 +                        rh->format = FMTSPEC;
175                  else
176                          rh->format = FMTBAD;
177                  return(0);
# Line 180 | Line 185 | headline(                      /* grok a header line */
185                  rh->primp = rh->mypri;
186                  return(0);
187          }
188 +        if (isncomp(s)) {
189 +                rh->ncs = ncompval(s);
190 +                return(0);
191 +        }
192 +        if (iswlsplit(s)) {
193 +                wlsplitval(rh->wpt, s);
194 +                return(0);
195 +        }
196          return(0);
197   }
198  
# Line 218 | Line 231 | FILE   *fp
231                          fgetresolu(xp, yp, inpf) < 0) {
232                  err = TM_E_BADFILE; goto done;
233          }
234 <        if (info.format == FMTUNK)              /* assume RGBE format */
234 >        if (info.format == FMTSPEC) {           /* valid spectrum? */
235 >                if (info.ncs <= 3) {
236 >                        err = TM_E_BADFILE; goto done;
237 >                }
238 >                if (info.wpt[0] == 0)
239 >                        memcpy(info.wpt, WLPART, sizeof(info.wpt));
240 >        } else if (info.format == FMTUNK)       /* assume RGBE format? */
241                  info.format = FMTRGB;
242 <        if (info.format == FMTRGB)
243 <                info.expos /= WHTEFFICACY;
225 <        else if (info.format == FMTCIE)
242 >
243 >        if (info.format == FMTCIE)
244                  info.primp = TM_XYZPRIM;
245 +        else
246 +                info.expos /= WHTEFFICACY;
247                                                  /* prepare library */
248          if ((err = tmSetSpace(tms, info.primp, 1./info.expos, NULL)) != TM_E_OK)
249                  goto done;
# Line 241 | Line 261 | FILE   *fp
261                  goto done;
262          err = TM_E_BADFILE;                     /* read & convert scanlines */
263          for (i = 0; i < *yp; i++) {
264 <                if (freadcolrs(scanin, *xp, inpf) < 0) {
264 >                if (fread2colrs(scanin, *xp, inpf, info.ncs, info.wpt) < 0) {
265                          err = TM_E_BADFILE; break;
266                  }
267                  err = tmCvColrs(tms, *lpp + (i * *xp),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines