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.2 by greg, Fri Mar 5 15:14:04 1993 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 + #ifdef  NTSC
43 + static float  xyz2rgbmat[3][3] = {      /* XYZ to RGB (NTSC) */
44 +        {1.73, -.48, -.26},
45 +        {-.81, 1.65, -.02},
46 +         {.08, -.17, 1.28}
47 + };
48 + #else
49 + static float xyz2rgbmat[3][3] = {       /* XYZ to RGB (color monitor) */
50 +         {2.739, -1.145, -.424},
51 +        {-1.119,  2.029,  .033},
52 +          {.138,  -.333, 1.105}
53 + };
54 + #endif
55  
56 +
57 +
58   spec_rgb(col, s, e)             /* compute RGB color from spectral range */
59   COLOR  col;
60   int  s, e;
# Line 60 | Line 77 | int  s, e;             /* starting and ending wavelengths */
77                  s = 0;
78  
79          e -= STARTWL;
80 +        if (e <= s) {
81 +                col[RED] = col[GRN] = col[BLU] = 0.0;
82 +                return;
83 +        }
84          if (e >= INCWL*(NINC - 1))
85                  e = INCWL*(NINC - 1) - 1;
86  
# Line 79 | Line 100 | int  s, e;             /* starting and ending wavelengths */
100   }
101  
102  
103 < cie_rgb(rgbcolor, ciecolor)             /* convert CIE to RGB (NTSC) */
103 > cie_rgb(rgbcolor, ciecolor)             /* convert CIE to RGB */
104   register COLOR  rgbcolor, ciecolor;
105   {
85        static float  cmat[3][3] = {
86                1.73, -.48, -.26,
87                -.81, 1.65, -.02,
88                 .08, -.17, 1.28,
89        };
106          register int  i;
107  
108          for (i = 0; i < 3; i++) {
109 <                rgbcolor[i] =   cmat[i][0]*ciecolor[0] +
110 <                                cmat[i][1]*ciecolor[1] +
111 <                                cmat[i][2]*ciecolor[2] ;
109 >                rgbcolor[i] =   xyz2rgbmat[i][0]*ciecolor[0] +
110 >                                xyz2rgbmat[i][1]*ciecolor[1] +
111 >                                xyz2rgbmat[i][2]*ciecolor[2] ;
112                  if (rgbcolor[i] < 0.0)
113                          rgbcolor[i] = 0.0;
114          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines