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

Comparing ray/src/common/color.h (file contents):
Revision 2.9 by greg, Fri Sep 2 12:02:17 1994 UTC vs.
Revision 2.10 by greg, Sun Oct 15 14:07:59 1995 UTC

# Line 16 | Line 16
16   #define  RED            0
17   #define  GRN            1
18   #define  BLU            2
19 < #define  EXP            3
19 > #define  CIEX           0       /* or, if input is XYZ... */
20 > #define  CIEY           1
21 > #define  CIEZ           2
22 > #define  EXP            3       /* exponent same for either format */
23   #define  COLXS          128     /* excess used for exponent */
24 + #define  WHT            3       /* used for RGBPRIMS type */
25  
26   typedef unsigned char  BYTE;    /* 8-bit unsigned integer */
27  
28 < typedef BYTE  COLR[4];          /* red, green, blue, exponent */
28 > typedef BYTE  COLR[4];          /* red, green, blue (or X,Y,Z), exponent */
29  
30 + typedef float  COLOR[3];        /* red, green, blue (or X,Y,Z) */
31 +
32 + typedef float  RGBPRIMS[4][2];  /* (x,y) chromaticities for RGBW */
33 + typedef float  (*RGBPRIMP)[2];  /* pointer to RGBPRIMS array */
34 +
35 + typedef float  COLORMAT[3][3];  /* color coordinate conversion matrix */
36 +
37   #define  copycolr(c1,c2)        (c1[0]=c2[0],c1[1]=c2[1], \
38                                  c1[2]=c2[2],c1[3]=c2[3])
39  
29 typedef float  COLOR[3];        /* red, green, blue */
30
40   #define  colval(col,pri)        ((col)[pri])
41  
42   #define  setcolor(col,r,g,b)    ((col)[RED]=(r),(col)[GRN]=(g),(col)[BLU]=(b))
# Line 60 | Line 69 | typedef float  COLOR[3];       /* red, green, blue */
69   #define  CIE_y_w                0.3333
70   #endif
71  
72 + #define  STDPRIMS       {CIE_x_r,CIE_y_r,CIE_x_g,CIE_y_g, \
73 +                                CIE_x_b,CIE_y_b,CIE_x_w,CIE_y_w}
74 +
75   #define CIE_D           (       CIE_x_r*(CIE_y_g - CIE_y_b) + \
76                                  CIE_x_g*(CIE_y_b - CIE_y_r) + \
77                                  CIE_x_b*(CIE_y_r - CIE_y_g)     )
# Line 82 | Line 94 | typedef float  COLOR[3];       /* red, green, blue */
94  
95   /* As of 9-94, CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243 */
96  
97 + /***** The following definitions are valid for RGB colors only... *****/
98 +
99   #define  bright(col)    (CIE_rf*(col)[RED]+CIE_gf*(col)[GRN]+CIE_bf*(col)[BLU])
100   #define  normbright(c)  ( ( (long)(CIE_rf*256.+.5)*(c)[RED] + \
101                              (long)(CIE_gf*256.+.5)*(c)[GRN] + \
# Line 98 | Line 112 | typedef float  COLOR[3];       /* red, green, blue */
112  
113   #define  luminance(col)         (WHTEFFICACY * bright(col))
114  
115 + /***** ...end of stuff specific to RGB colors *****/
116 +
117   #define  intens(col)            ( (col)[0] > (col)[1] \
118                                  ? (col)[0] > (col)[2] ? (col)[0] : (col)[2] \
119                                  : (col)[1] > (col)[2] ? (col)[1] : (col)[2] )
# Line 113 | Line 129 | typedef float  COLOR[3];       /* red, green, blue */
129  
130                                  /* picture format identifier */
131   #define  COLRFMT                "32-bit_rle_rgbe"
132 + #define  CIEFMT                 "32-bit_rle_xyze"
133 + #define  PICFMT                 "32-bit_rle_???e"       /* matches either */
134 + #define  LPICFMT                15                      /* max format id len */
135  
136                                  /* macros for exposures */
137   #define  EXPOSSTR               "EXPOSURE="
# Line 128 | Line 147 | typedef float  COLOR[3];       /* red, green, blue */
147   #define  aspectval(hl)          atof((hl)+LASPECTSTR)
148   #define  fputaspect(pa,fp)      fprintf(fp,"%s%f\n",ASPECTSTR,pa)
149  
150 +                                /* macros for primary specifications */
151 + #define  PRIMARYSTR             "PRIMARIES="
152 + #define  LPRIMARYSTR            10
153 + #define  isprims(hl)            (!strncmp(hl,PRIMARYSTR,LPRIMARYSTR))
154 + #define  primsval(p,hl)         sscanf(hl+LPRIMARYSTR, \
155 +                                        "%f %f %f %f %f %f %f %f", \
156 +                                        &(p)[RED][CIEX],&(p)[RED][CIEY], \
157 +                                        &(p)[GRN][CIEX],&(p)[GRN][CIEY], \
158 +                                        &(p)[BLU][CIEX],&(p)[BLU][CIEY], \
159 +                                        &(p)[WHT][CIEX],&(p)[WHT][CIEY])
160 + #define  fputprims(p,fp)        fprintf(fp, \
161 +                                "%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",\
162 +                                        PRIMARYSTR, \
163 +                                        (p)[RED][CIEX],(p)[RED][CIEY], \
164 +                                        (p)[GRN][CIEX],(p)[GRN][CIEY], \
165 +                                        (p)[BLU][CIEX],(p)[BLU][CIEY], \
166 +                                        (p)[WHT][CIEX],(p)[WHT][CIEY])
167 +
168                                  /* macros for color correction */
169   #define  COLCORSTR              "COLORCORR="
170   #define  LCOLCORSTR             10
# Line 139 | Line 176 | typedef float  COLOR[3];       /* red, green, blue */
176  
177   #ifdef  DCL_ATOF
178   extern double  atof(), ldexp(), frexp();
179 + #endif
180 +
181 + /*
182 + * Conversions to and from XYZ space generally don't apply WHTEFFICACY.
183 + * If you need Y to be luminance (cd/m^2), this must be applied when
184 + * converting from radiance (watts/sr/m^2).
185 + */
186 +
187 + extern RGBPRIMS  stdprims;              /* standard primary chromaticities */
188 + extern COLORMAT  rgb2xyzmat;            /* RGB to XYZ conversion matrix */
189 + extern COLORMAT  xyz2rgbmat;            /* XYZ to RGB conversion matrix */
190 +
191 + #define  cie_rgb(rgb,xyz)       colortrans(rgb,xyz2rgbmat,xyz)
192 + #define  rgb_cie(xyz,rgb)       colortrans(xyz,rgb2xyzmat,rgb)
193 +
194 + #ifdef BSD
195 + #define  cpcolormat(md,ms)      bcopy((char *)ms,(char *)md,sizeof(COLORMAT))
196 + #else
197 + extern char  *memcpy();
198 + #define  cpcolormat(md,ms)      (void)memcpy((char *)md,(char *)ms,sizeof(COLORMAT))
199   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines