1 |
+ |
/* Copyright (c) 1990 Regents of the University of California */ |
2 |
+ |
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
5 |
|
#endif |
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; |
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 |
|
|
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 |
|
} |