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.30 by greg, Thu May 21 18:08:43 2009 UTC vs.
Revision 2.37 by greg, Fri Apr 14 15:49:32 2023 UTC

# Line 2 | Line 2
2   /*
3   *  color.h - header for routines using pixel color values.
4   *
5 *  Must be included after X11 headers, since they declare a BYTE type.
6 *
5   *  Two color representations are used, one for calculation and
6   *  another for storage.  Calculation is done with three floats
7   *  for speed.  Stored color values use 4 bytes which contain
# Line 12 | Line 10
10   #ifndef _RAD_COLOR_H_
11   #define _RAD_COLOR_H_
12  
13 + #include <stdio.h>
14   #include <stdlib.h>
15  
16   #ifdef __cplusplus
# Line 28 | Line 27 | extern "C" {
27   #define  COLXS          128     /* excess used for exponent */
28   #define  WHT            3       /* used for RGBPRIMS type */
29  
30 < #undef  BYTE
31 < #define  BYTE   unsigned char   /* 8-bit unsigned integer */
30 > #undef uby8
31 > #define uby8  unsigned char     /* 8-bit unsigned integer */
32  
33 < typedef BYTE  COLR[4];          /* red, green, blue (or X,Y,Z), exponent */
33 > typedef uby8  COLR[4];          /* red, green, blue (or X,Y,Z), exponent */
34  
35   typedef float COLORV;
36   typedef COLORV  COLOR[3];       /* red, green, blue (or X,Y,Z) */
# Line 56 | Line 55 | typedef float  COLORMAT[3][3]; /* color coordinate con
55  
56   #define  multcolor(c1,c2)       ((c1)[0]*=(c2)[0],(c1)[1]*=(c2)[1],(c1)[2]*=(c2)[2])
57  
58 < #ifdef  NTSC
58 > #if defined(NTSC_RGB)
59   #define  CIE_x_r                0.670           /* standard NTSC primaries */
60   #define  CIE_y_r                0.330
61   #define  CIE_x_g                0.210
62   #define  CIE_y_g                0.710
63   #define  CIE_x_b                0.140
64   #define  CIE_y_b                0.080
65 < #define  CIE_x_w                0.3333          /* use true white */
66 < #define  CIE_y_w                0.3333
65 > #define  CIE_x_w                (1./3.)         /* use EE white */
66 > #define  CIE_y_w                (1./3.)
67 > #elif defined(SHARP_RGB)
68 > #define  CIE_x_r                0.6898          /* "sharp" RGB primaries */
69 > #define  CIE_y_r                0.3206
70 > #define  CIE_x_g                0.0736
71 > #define  CIE_y_g                0.9003
72 > #define  CIE_x_b                0.1166
73 > #define  CIE_y_b                0.0374
74 > #define  CIE_x_w                (1./3.)         /* use EE white */
75 > #define  CIE_y_w                (1./3.)
76   #else
77   #define  CIE_x_r                0.640           /* nominal CRT primaries */
78   #define  CIE_y_r                0.330
# Line 72 | Line 80 | typedef float  COLORMAT[3][3]; /* color coordinate con
80   #define  CIE_y_g                0.600
81   #define  CIE_x_b                0.150
82   #define  CIE_y_b                0.060
83 < #define  CIE_x_w                0.3333          /* use true white */
84 < #define  CIE_y_w                0.3333
83 > #define  CIE_x_w                (1./3.)         /* use EE white */
84 > #define  CIE_y_w                (1./3.)
85   #endif
86  
87   #define  STDPRIMS       {{CIE_x_r,CIE_y_r},{CIE_x_g,CIE_y_g}, \
# Line 99 | Line 107 | typedef float  COLORMAT[3][3]; /* color coordinate con
107   #define CIE_gf          (CIE_y_g*CIE_C_gD/CIE_D)
108   #define CIE_bf          (CIE_y_b*CIE_C_bD/CIE_D)
109  
110 < /* As of 9-94, CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243 */
110 > /* Default CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243 */
111  
112   /***** The following definitions are valid for RGB colors only... *****/
113  
# Line 145 | Line 153 | typedef float  COLORMAT[3][3]; /* color coordinate con
153   #define  LEXPOSSTR              9
154   #define  isexpos(hl)            (!strncmp(hl,EXPOSSTR,LEXPOSSTR))
155   #define  exposval(hl)           atof((hl)+LEXPOSSTR)
156 < #define  fputexpos(ex,fp)       fprintf(fp,"%s%e\n",EXPOSSTR,ex)
156 > #define  fputexpos(ex,fp)       fprintf(fp,"%s%.4e\n",EXPOSSTR,ex)
157  
158                                  /* macros for pixel aspect ratios */
159   #define  ASPECTSTR              "PIXASPECT="
# Line 158 | Line 166 | typedef float  COLORMAT[3][3]; /* color coordinate con
166   #define  PRIMARYSTR             "PRIMARIES="
167   #define  LPRIMARYSTR            10
168   #define  isprims(hl)            (!strncmp(hl,PRIMARYSTR,LPRIMARYSTR))
169 < #define  primsval(p,hl)         sscanf((hl)+LPRIMARYSTR, \
169 > #define  primsval(p,hl)         (sscanf((hl)+LPRIMARYSTR, \
170                                          "%f %f %f %f %f %f %f %f", \
171                                          &(p)[RED][CIEX],&(p)[RED][CIEY], \
172                                          &(p)[GRN][CIEX],&(p)[GRN][CIEY], \
173                                          &(p)[BLU][CIEX],&(p)[BLU][CIEY], \
174 <                                        &(p)[WHT][CIEX],&(p)[WHT][CIEY])
174 >                                        &(p)[WHT][CIEX],&(p)[WHT][CIEY]) == 8)
175   #define  fputprims(p,fp)        fprintf(fp, \
176                                  "%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",\
177                                          PRIMARYSTR, \
# Line 201 | Line 209 | extern COLOR  cblack, cwhite;  /* black (0,0,0) and whi
209   #define  cpcolormat(md,ms)      memcpy((void *)md,(void *)ms,sizeof(COLORMAT))
210  
211                                          /* defined in color.c */
212 < extern char     *tempbuffer(unsigned int len);
212 > extern void     *tempbuffer(unsigned int len);
213   extern int      fwritecolrs(COLR *scanline, int len, FILE *fp);
214   extern int      freadcolrs(COLR *scanline, int len, FILE *fp);
215   extern int      fwritescan(COLOR *scanline, int len, FILE *fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines