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

Comparing ray/src/common/spec_rgb.c (file contents):
Revision 2.5 by greg, Sun Oct 15 14:08:01 1995 UTC vs.
Revision 2.7 by greg, Thu Jan 30 19:14:39 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1990 Regents of the University of California */
1 > /* Copyright (c) 1997 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 109 | Line 109 | int  s, e;             /* starting and ending wavelengths */
109   }
110  
111  
112 < colortrans(c2, mat, c1)         /* convert c1 by mat and put into c2 */
112 > colortrans(c2, mat, c1, noneg)  /* convert c1 by mat and put into c2 */
113   register COLORMAT  mat;
114   register COLOR  c1, c2;
115 + int     noneg;
116   {
117          static float  cout[3];
118  
119          cout[0] = mat[0][0]*c1[0] + mat[0][1]*c1[1] + mat[0][2]*c1[2];
120          cout[1] = mat[1][0]*c1[0] + mat[1][1]*c1[1] + mat[1][2]*c1[2];
121          cout[2] = mat[2][0]*c1[0] + mat[2][1]*c1[1] + mat[2][2]*c1[2];
122 <        if((c2[0] = cout[0]) < 0.) c2[0] = 0.;
123 <        if((c2[1] = cout[1]) < 0.) c2[1] = 0.;
124 <        if((c2[2] = cout[2]) < 0.) c2[2] = 0.;
122 >        if (!noneg)
123 >                return;
124 >        if ((c2[0] = cout[0]) < 0.) c2[0] = 0.;
125 >        if ((c2[1] = cout[1]) < 0.) c2[1] = 0.;
126 >        if ((c2[2] = cout[2]) < 0.) c2[2] = 0.;
127   }
128  
129  
# Line 145 | Line 148 | register RGBPRIMS  pr;
148   {
149          double  C_rD, C_gD, C_bD;
150  
151 +        if (pr == stdprims) {   /* can use xyz2rgbmat */
152 +                cpcolormat(mat, xyz2rgbmat);
153 +                return;
154 +        }
155          C_rD = (1./pr[WHT][CIEY]) *
156                          ( pr[WHT][CIEX]*(pr[GRN][CIEY] - pr[BLU][CIEY]) -
157                            pr[WHT][CIEY]*(pr[GRN][CIEX] - pr[BLU][CIEX]) +
# Line 191 | Line 198 | register RGBPRIMS  pr;
198   {
199          double  C_rD, C_gD, C_bD, D;
200  
201 +        if (pr == stdprims) {   /* can use rgb2xyzmat */
202 +                cpcolormat(mat, rgb2xyzmat);
203 +                return;
204 +        }
205          C_rD = (1./pr[WHT][CIEY]) *
206                          ( pr[WHT][CIEX]*(pr[GRN][CIEY] - pr[BLU][CIEY]) -
207                            pr[WHT][CIEY]*(pr[GRN][CIEX] - pr[BLU][CIEX]) +
# Line 224 | Line 235 | RGBPRIMS  pr1, pr2;
235   {
236          COLORMAT  pr1toxyz, xyztopr2;
237  
238 <        if (pr1 == stdprims)    /* can use rgb2xyzmat */
239 <                cpcolormat(pr1toxyz, rgb2xyzmat);
240 <        else                    /* otherwise compute it */
241 <                comprgb2xyzmat(pr1toxyz, pr1);
242 <        if (pr2 == stdprims)    /* can use xyz2rgbmat */
243 <                cpcolormat(xyztopr2, xyz2rgbmat);
244 <        else                    /* otherwise compute it */
245 <                compxyz2rgbmat(xyztopr2, pr2);
238 >        if (pr1 == pr2) {
239 >                mat[0][0] = mat[1][1] = mat[2][2] = 1.0;
240 >                mat[0][1] = mat[0][2] = mat[1][0] =
241 >                mat[1][2] = mat[2][0] = mat[2][1] = 0.0;
242 >                return;
243 >        }
244 >        comprgb2xyzmat(pr1toxyz, pr1);
245 >        compxyz2rgbmat(xyztopr2, pr2);
246                                  /* combine transforms */
247          multcolormat(mat, pr1toxyz, xyztopr2);
248   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines