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

Comparing ray/src/px/pcond2.c (file contents):
Revision 3.7 by greg, Fri Jan 31 15:56:20 1997 UTC vs.
Revision 3.9 by gwlarson, Mon Jan 25 11:51:37 1999 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include "pcond.h"
12 + #include "warp3d.h"
13  
14  
15   RGBPRIMP        inprims = stdprims;     /* input primaries */
# Line 19 | Line 20 | double (*lumf)() = rgblum;             /* input luminance functio
20   double  inpexp = 1.0;                   /* input exposure value */
21  
22   char    *mbcalfile = NULL;              /* macbethcal mapping file */
23 + char    *cwarpfile = NULL;              /* color space warping file */
24  
25   static struct mbc {
26          COLORMAT        cmat;
# Line 26 | Line 28 | static struct mbc {
28          COLOR   cmin, cmax;
29   }       mbcond;                         /* macbethcal conditioning struct */
30  
31 + static WARP3D   *cwarp;                 /* color warping structure */
32 +
33   static COLOR    *scanbuf;               /* scanline processing buffer */
34   static int      nread;                  /* number of scanlines processed */
35  
# Line 61 | Line 65 | COLOR *
65   nextscan()                              /* read and condition next scanline */
66   {
67          if (nread >= numscans(&inpres)) {
68 +                if (cwarpfile != NULL)
69 +                        free3dw(cwarp);
70                  free((char *)scanbuf);
71                  return(scanbuf = NULL);
72          }
# Line 81 | Line 87 | nextscan()                             /* read and condition next scanline */
87                  mapscan(scanbuf, scanlen(&inpres));
88          if (mbcalfile != NULL)                  /* device color correction */
89                  mbscan(scanbuf, scanlen(&inpres), &mbcond);
90 +        else if (cwarpfile != NULL)             /* device color space warp */
91 +                cwscan(scanbuf, scanlen(&inpres), cwarp);
92          else if (lumf == cielum | inprims != outprims)
93                  matscan(scanbuf, scanlen(&inpres), mbcond.cmat);
94          nread++;
# Line 93 | Line 101 | firstscan()                            /* return first processed scanline */
101   {
102          if (mbcalfile != NULL)          /* load macbethcal file */
103                  getmbcalfile(mbcalfile, &mbcond);
104 <        else
104 >        else if (cwarpfile != NULL) {
105 >                if ((cwarp = load3dw(cwarpfile, NULL)) == NULL)
106 >                        syserror(cwarpfile);
107 >        } else
108                  if (lumf == rgblum)
109                          comprgb2rgbmat(mbcond.cmat, inprims, outprims);
110                  else
# Line 157 | Line 168 | register struct mbc    *mb;
168   }
169  
170  
171 + cwscan(sl, len, wp)                     /* apply color space warp to scaline */
172 + COLOR   *sl;
173 + int     len;
174 + WARP3D  *wp;
175 + {
176 +        int     rval;
177 +
178 +        while (len--) {
179 +                rval = warp3d(sl[0], sl[0], wp);
180 +                if (rval & W3ERROR)
181 +                        syserror("warp3d");
182 +                if (rval & W3BADMAP) {
183 +                        fprintf(stderr, "%s: %s: bad color space map\n",
184 +                                        progname, cwarpfile);
185 +                        exit(1);
186 +                }
187 +                clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite);
188 +                sl++;
189 +        }
190 + }
191 +
192 +
193   getmbcalfile(fn, mb)                    /* load macbethcal file */
194   char    *fn;
195   register struct mbc     *mb;
# Line 220 | Line 253 | register struct mbc    *mb;
253                          inpflags |= 040;
254                  else if (!(inpflags & 0100) &&
255                                  sscanf(buf,
256 <                                "r = %f*r1 + %f*g1 + %f*b1",
256 >                                "ro = %f*rn + %f*gn + %f*bn",
257                                  &mb->cmat[0][0], &mb->cmat[0][1],
258                                  &mb->cmat[0][2]) == 3)
259                          inpflags |= 0100;
260                  else if (!(inpflags & 0200) &&
261                                  sscanf(buf,
262 <                                "g = %f*r1 + %f*g1 + %f*b1",
262 >                                "go = %f*rn + %f*gn + %f*bn",
263                                  &mb->cmat[1][0], &mb->cmat[1][1],
264                                  &mb->cmat[1][2]) == 3)
265                          inpflags |= 0200;
266                  else if (!(inpflags & 0400) &&
267                                  sscanf(buf,
268 <                                "b = %f*r1 + %f*g1 + %f*b1",
268 >                                "bo = %f*rn + %f*gn + %f*bn",
269                                  &mb->cmat[2][0], &mb->cmat[2][1],
270                                  &mb->cmat[2][2]) == 3)
271                          inpflags |= 0400;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines