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 1.1 by greg, Sat Sep 22 10:44:56 1990 UTC vs.
Revision 2.3 by greg, Wed Jun 29 18:16:58 1994 UTC

# Line 1 | Line 1
1 + /* Copyright (c) 1990 Regents of the University of California */
2 +
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
5   #endif
# Line 37 | Line 39 | static BYTE  chroma[3][NINC] = {
39          }
40   };
41  
42 + static float  xyz2rgbmat[3][3] = {      /* XYZ to RGB */
43 +        {(CIE_y_g - CIE_y_b - CIE_x_b*CIE_y_g + CIE_y_b*CIE_x_g)/CIE_C_rD,
44 +         (CIE_x_b - CIE_x_g - CIE_x_b*CIE_y_g + CIE_x_g*CIE_y_b)/CIE_C_rD,
45 +         (CIE_x_g*CIE_y_b - CIE_x_b*CIE_y_g)/CIE_C_rD},
46 +        {(CIE_y_b - CIE_y_r - CIE_y_b*CIE_x_r + CIE_y_r*CIE_x_b)/CIE_C_gD,
47 +         (CIE_x_r - CIE_x_b - CIE_x_r*CIE_y_b + CIE_x_b*CIE_y_r)/CIE_C_gD,
48 +         (CIE_x_b*CIE_y_r - CIE_x_r*CIE_y_b)/CIE_C_gD},
49 +        {(CIE_y_r - CIE_y_g - CIE_y_r*CIE_x_g + CIE_y_g*CIE_x_r)/CIE_C_bD,
50 +         (CIE_x_g - CIE_x_r - CIE_x_g*CIE_y_r + CIE_x_r*CIE_y_g)/CIE_C_bD,
51 +         (CIE_x_r*CIE_y_g - CIE_x_g*CIE_y_r)/CIE_C_bD}
52 + };
53  
54 +
55 +
56   spec_rgb(col, s, e)             /* compute RGB color from spectral range */
57   COLOR  col;
58   int  s, e;
# Line 60 | Line 75 | int  s, e;             /* starting and ending wavelengths */
75                  s = 0;
76  
77          e -= STARTWL;
78 +        if (e <= s) {
79 +                col[RED] = col[GRN] = col[BLU] = 0.0;
80 +                return;
81 +        }
82          if (e >= INCWL*(NINC - 1))
83                  e = INCWL*(NINC - 1) - 1;
84  
# Line 79 | Line 98 | int  s, e;             /* starting and ending wavelengths */
98   }
99  
100  
101 < cie_rgb(rgbcolor, ciecolor)             /* convert CIE to RGB (NTSC) */
101 > cie_rgb(rgbcolor, ciecolor)             /* convert CIE to RGB */
102   register COLOR  rgbcolor, ciecolor;
103   {
85        static float  cmat[3][3] = {
86                1.73, -.48, -.26,
87                -.81, 1.65, -.02,
88                 .08, -.17, 1.28,
89        };
104          register int  i;
105  
106          for (i = 0; i < 3; i++) {
107 <                rgbcolor[i] =   cmat[i][0]*ciecolor[0] +
108 <                                cmat[i][1]*ciecolor[1] +
109 <                                cmat[i][2]*ciecolor[2] ;
107 >                rgbcolor[i] =   xyz2rgbmat[i][0]*ciecolor[0] +
108 >                                xyz2rgbmat[i][1]*ciecolor[1] +
109 >                                xyz2rgbmat[i][2]*ciecolor[2] ;
110                  if (rgbcolor[i] < 0.0)
111                          rgbcolor[i] = 0.0;
112          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines