--- ray/src/common/color.h 2003/06/06 16:38:47 2.21 +++ ray/src/common/color.h 2009/05/21 18:08:43 2.30 @@ -1,4 +1,4 @@ -/* RCSid $Id: color.h,v 2.21 2003/06/06 16:38:47 schorsch Exp $ */ +/* RCSid $Id: color.h,v 2.30 2009/05/21 18:08:43 greg Exp $ */ /* * color.h - header for routines using pixel color values. * @@ -11,16 +11,13 @@ */ #ifndef _RAD_COLOR_H_ #define _RAD_COLOR_H_ + +#include + #ifdef __cplusplus extern "C" { #endif - -#include "copyright.h" - -#include -#include - #define RED 0 #define GRN 1 #define BLU 2 @@ -36,7 +33,8 @@ extern "C" { typedef BYTE COLR[4]; /* red, green, blue (or X,Y,Z), exponent */ -typedef float COLOR[3]; /* red, green, blue (or X,Y,Z) */ +typedef float COLORV; +typedef COLORV COLOR[3]; /* red, green, blue (or X,Y,Z) */ typedef float RGBPRIMS[4][2]; /* (x,y) chromaticities for RGBW */ typedef float (*RGBPRIMP)[2]; /* pointer to RGBPRIMS array */ @@ -116,7 +114,7 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define D65EFFICACY 203. /* standard illuminant D65 */ #define INCEFFICACY 160. /* illuminant A (incand.) */ #define SUNEFFICACY 208. /* illuminant B (solar dir.) */ -#define SKYEFFICACY D65EFFICACY /* skylight */ +#define SKYEFFICACY D65EFFICACY /* skylight (should be 110) */ #define DAYEFFICACY D65EFFICACY /* combined sky and solar */ #define luminance(col) (WHTEFFICACY * bright(col)) @@ -160,7 +158,7 @@ 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], \ @@ -178,7 +176,7 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define COLCORSTR "COLORCORR=" #define LCOLCORSTR 10 #define iscolcor(hl) (!strncmp(hl,COLCORSTR,LCOLCORSTR)) -#define colcorval(cc,hl) sscanf(hl+LCOLCORSTR,"%f %f %f", \ +#define colcorval(cc,hl) sscanf((hl)+LCOLCORSTR,"%f %f %f", \ &(cc)[RED],&(cc)[GRN],&(cc)[BLU]) #define fputcolcor(cc,fp) fprintf(fp,"%s %f %f %f\n",COLCORSTR, \ (cc)[RED],(cc)[GRN],(cc)[BLU]) @@ -200,11 +198,7 @@ extern COLOR cblack, cwhite; /* black (0,0,0) and whi #define rgb_cie(xyz,rgb) colortrans(xyz,rgb2xyzmat,rgb) -#ifdef BSD -#define cpcolormat(md,ms) bcopy((void *)ms,(void *)md,sizeof(COLORMAT)) -#else #define cpcolormat(md,ms) memcpy((void *)md,(void *)ms,sizeof(COLORMAT)) -#endif /* defined in color.c */ extern char *tempbuffer(unsigned int len); @@ -224,17 +218,18 @@ extern int clipgamut(COLOR col, double brt, int gamut, extern void colortrans(COLOR c2, COLORMAT mat, COLOR c1); extern void multcolormat(COLORMAT m3, COLORMAT m2, COLORMAT m1); -extern void compxyz2rgbmat(COLORMAT mat, RGBPRIMS pr); -extern void comprgb2xyzmat(COLORMAT mat, RGBPRIMS pr); -extern void comprgb2rgbmat(COLORMAT mat, RGBPRIMS pr1, RGBPRIMS pr2); -extern void compxyzWBmat(COLORMAT mat, float wht1[2], +extern int colorprimsOK(RGBPRIMS pr); +extern int compxyz2rgbmat(COLORMAT mat, RGBPRIMS pr); +extern int comprgb2xyzmat(COLORMAT mat, RGBPRIMS pr); +extern int comprgb2rgbmat(COLORMAT mat, RGBPRIMS pr1, RGBPRIMS pr2); +extern int compxyzWBmat(COLORMAT mat, float wht1[2], float wht2[2]); -extern void compxyz2rgbWBmat(COLORMAT mat, RGBPRIMS pr); -extern void comprgb2xyzWBmat(COLORMAT mat, RGBPRIMS pr); -extern void comprgb2rgbWBmat(COLORMAT mat, RGBPRIMS pr1, RGBPRIMS pr2); +extern int compxyz2rgbWBmat(COLORMAT mat, RGBPRIMS pr); +extern int comprgb2xyzWBmat(COLORMAT mat, RGBPRIMS pr); +extern int comprgb2rgbWBmat(COLORMAT mat, RGBPRIMS pr1, RGBPRIMS pr2); /* defined in colrops.c */ -extern int setcolrcor(double (*f)(), double a2); -extern int setcolrinv(double (*f)(), double a2); +extern int setcolrcor(double (*f)(double, double), double a2); +extern int setcolrinv(double (*f)(double, double), double a2); extern int setcolrgam(double g); extern int colrs_gambs(COLR *scan, int len); extern int gambs_colrs(COLR *scan, int len);