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.8 by greg, Wed Feb 5 16:08:18 1997 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 152 | Line 163 | register struct mbc    *mb;
163                                          (d - mb->xa[i][j])*mb->ya[i][j+1] ) /
164                                          (mb->xa[i][j+1] - mb->xa[i][j]);
165                  }
166 +                sl++;
167 +        }
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines