--- ray/src/common/color.h 2011/05/20 02:06:38 2.31 +++ ray/src/common/color.h 2023/04/14 15:49:32 2.37 @@ -1,4 +1,4 @@ -/* RCSid $Id: color.h,v 2.31 2011/05/20 02:06:38 greg Exp $ */ +/* RCSid $Id: color.h,v 2.37 2023/04/14 15:49:32 greg Exp $ */ /* * color.h - header for routines using pixel color values. * @@ -10,6 +10,7 @@ #ifndef _RAD_COLOR_H_ #define _RAD_COLOR_H_ +#include #include #ifdef __cplusplus @@ -54,15 +55,24 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define multcolor(c1,c2) ((c1)[0]*=(c2)[0],(c1)[1]*=(c2)[1],(c1)[2]*=(c2)[2]) -#ifdef NTSC +#if defined(NTSC_RGB) #define CIE_x_r 0.670 /* standard NTSC primaries */ #define CIE_y_r 0.330 #define CIE_x_g 0.210 #define CIE_y_g 0.710 #define CIE_x_b 0.140 #define CIE_y_b 0.080 -#define CIE_x_w 0.3333 /* use true white */ -#define CIE_y_w 0.3333 +#define CIE_x_w (1./3.) /* use EE white */ +#define CIE_y_w (1./3.) +#elif defined(SHARP_RGB) +#define CIE_x_r 0.6898 /* "sharp" RGB primaries */ +#define CIE_y_r 0.3206 +#define CIE_x_g 0.0736 +#define CIE_y_g 0.9003 +#define CIE_x_b 0.1166 +#define CIE_y_b 0.0374 +#define CIE_x_w (1./3.) /* use EE white */ +#define CIE_y_w (1./3.) #else #define CIE_x_r 0.640 /* nominal CRT primaries */ #define CIE_y_r 0.330 @@ -70,8 +80,8 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define CIE_y_g 0.600 #define CIE_x_b 0.150 #define CIE_y_b 0.060 -#define CIE_x_w 0.3333 /* use true white */ -#define CIE_y_w 0.3333 +#define CIE_x_w (1./3.) /* use EE white */ +#define CIE_y_w (1./3.) #endif #define STDPRIMS {{CIE_x_r,CIE_y_r},{CIE_x_g,CIE_y_g}, \ @@ -97,7 +107,7 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define CIE_gf (CIE_y_g*CIE_C_gD/CIE_D) #define CIE_bf (CIE_y_b*CIE_C_bD/CIE_D) -/* As of 9-94, CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243 */ +/* Default CIE_rf=.265074126, CIE_gf=.670114631 and CIE_bf=.064811243 */ /***** The following definitions are valid for RGB colors only... *****/ @@ -143,7 +153,7 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define LEXPOSSTR 9 #define isexpos(hl) (!strncmp(hl,EXPOSSTR,LEXPOSSTR)) #define exposval(hl) atof((hl)+LEXPOSSTR) -#define fputexpos(ex,fp) fprintf(fp,"%s%e\n",EXPOSSTR,ex) +#define fputexpos(ex,fp) fprintf(fp,"%s%.4e\n",EXPOSSTR,ex) /* macros for pixel aspect ratios */ #define ASPECTSTR "PIXASPECT=" @@ -156,12 +166,12 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define PRIMARYSTR "PRIMARIES=" #define LPRIMARYSTR 10 #define isprims(hl) (!strncmp(hl,PRIMARYSTR,LPRIMARYSTR)) -#define primsval(p,hl) sscanf((hl)+LPRIMARYSTR, \ +#define primsval(p,hl) (sscanf((hl)+LPRIMARYSTR, \ "%f %f %f %f %f %f %f %f", \ &(p)[RED][CIEX],&(p)[RED][CIEY], \ &(p)[GRN][CIEX],&(p)[GRN][CIEY], \ &(p)[BLU][CIEX],&(p)[BLU][CIEY], \ - &(p)[WHT][CIEX],&(p)[WHT][CIEY]) + &(p)[WHT][CIEX],&(p)[WHT][CIEY]) == 8) #define fputprims(p,fp) fprintf(fp, \ "%s %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n",\ PRIMARYSTR, \ @@ -199,7 +209,7 @@ extern COLOR cblack, cwhite; /* black (0,0,0) and whi #define cpcolormat(md,ms) memcpy((void *)md,(void *)ms,sizeof(COLORMAT)) /* defined in color.c */ -extern char *tempbuffer(unsigned int len); +extern void *tempbuffer(unsigned int len); extern int fwritecolrs(COLR *scanline, int len, FILE *fp); extern int freadcolrs(COLR *scanline, int len, FILE *fp); extern int fwritescan(COLOR *scanline, int len, FILE *fp);