--- ray/src/common/color.h 1995/10/15 14:07:59 2.10 +++ ray/src/common/color.h 2003/05/13 17:58:32 2.20 @@ -1,11 +1,8 @@ -/* Copyright (c) 1991 Regents of the University of California */ - -/* SCCSid "$SunId$ LBL" */ - +/* RCSid $Id: color.h,v 2.20 2003/05/13 17:58:32 greg Exp $ */ /* * color.h - header for routines using pixel color values. * - * 12/31/85 + * Must be included after X11 headers, since they declare a BYTE type. * * Two color representations are used, one for calculation and * another for storage. Calculation is done with three floats @@ -13,6 +10,15 @@ * three single byte mantissas and a common exponent. */ +#include "copyright.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + #define RED 0 #define GRN 1 #define BLU 2 @@ -23,7 +29,8 @@ #define COLXS 128 /* excess used for exponent */ #define WHT 3 /* used for RGBPRIMS type */ -typedef unsigned char BYTE; /* 8-bit unsigned integer */ +#undef BYTE +#define BYTE unsigned char /* 8-bit unsigned integer */ typedef BYTE COLR[4]; /* red, green, blue (or X,Y,Z), exponent */ @@ -69,8 +76,8 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define CIE_y_w 0.3333 #endif -#define STDPRIMS {CIE_x_r,CIE_y_r,CIE_x_g,CIE_y_g, \ - CIE_x_b,CIE_y_b,CIE_x_w,CIE_y_w} +#define STDPRIMS {{CIE_x_r,CIE_y_r},{CIE_x_g,CIE_y_g}, \ + {CIE_x_b,CIE_y_b},{CIE_x_w,CIE_y_w}} #define CIE_D ( CIE_x_r*(CIE_y_g - CIE_y_b) + \ CIE_x_g*(CIE_y_b - CIE_y_r) + \ @@ -174,26 +181,100 @@ typedef float COLORMAT[3][3]; /* color coordinate con #define fputcolcor(cc,fp) fprintf(fp,"%s %f %f %f\n",COLCORSTR, \ (cc)[RED],(cc)[GRN],(cc)[BLU]) -#ifdef DCL_ATOF -extern double atof(), ldexp(), frexp(); -#endif - /* * Conversions to and from XYZ space generally don't apply WHTEFFICACY. * If you need Y to be luminance (cd/m^2), this must be applied when * converting from radiance (watts/sr/m^2). */ -extern RGBPRIMS stdprims; /* standard primary chromaticities */ -extern COLORMAT rgb2xyzmat; /* RGB to XYZ conversion matrix */ -extern COLORMAT xyz2rgbmat; /* XYZ to RGB conversion matrix */ +extern RGBPRIMS stdprims; /* standard primary chromaticities */ +extern COLORMAT rgb2xyzmat; /* RGB to XYZ conversion matrix */ +extern COLORMAT xyz2rgbmat; /* XYZ to RGB conversion matrix */ +extern COLOR cblack, cwhite; /* black (0,0,0) and white (1,1,1) */ -#define cie_rgb(rgb,xyz) colortrans(rgb,xyz2rgbmat,xyz) +#define CGAMUT_LOWER 01 +#define CGAMUT_UPPER 02 +#define CGAMUT (CGAMUT_LOWER|CGAMUT_UPPER) + #define rgb_cie(xyz,rgb) colortrans(xyz,rgb2xyzmat,rgb) #ifdef BSD -#define cpcolormat(md,ms) bcopy((char *)ms,(char *)md,sizeof(COLORMAT)) +#define cpcolormat(md,ms) bcopy((void *)ms,(void *)md,sizeof(COLORMAT)) #else -extern char *memcpy(); -#define cpcolormat(md,ms) (void)memcpy((char *)md,(char *)ms,sizeof(COLORMAT)) +#define cpcolormat(md,ms) memcpy((void *)md,(void *)ms,sizeof(COLORMAT)) +#endif + +#ifdef NOPROTO + /* defined in color.c */ +extern char *tempbuffer(); +extern int fwritecolrs(); +extern int freadcolrs(); +extern int fwritescan(); +extern int freadscan(); +extern void setcolr(); +extern void colr_color(); +extern int bigdiff(); + /* defined in spec_rgb.c */ +extern void spec_rgb(); +extern void spec_cie(); +extern void cie_rgb(); +extern int clipgamut(); +extern void colortrans(); +extern void multcolormat(); +extern void compxyz2rgbmat(); +extern void comprgb2xyzmat(); +extern void comprgb2rgbmat(); +extern void compxyzWBmat(); +extern void compxyz2rgbWBmat(); +extern void comprgb2xyzWBmat(); +extern void comprgb2rgbWBmat(); + /* defined in colrops.c */ +extern int setcolrcor(); +extern int setcolrinv(); +extern int setcolrgam(); +extern int colrs_gambs(); +extern int gambs_colrs(); +extern void shiftcolrs(); +extern void normcolrs(); + +#else + /* defined in color.c */ +extern char *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); +extern int freadscan(COLOR *scanline, int len, FILE *fp); +extern void setcolr(COLR clr, double r, double g, double b); +extern void colr_color(COLOR col, COLR clr); +extern int bigdiff(COLOR c1, COLOR c2, double md); + /* defined in spec_rgb.c */ +extern void spec_rgb(COLOR col, int s, int e); +extern void spec_cie(COLOR col, int s, int e); +extern void cie_rgb(COLOR rgb, COLOR xyz); +extern int clipgamut(COLOR col, double brt, int gamut, + COLOR lower, COLOR upper); +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], + 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); + /* defined in colrops.c */ +extern int setcolrcor(double (*f)(), double a2); +extern int setcolrinv(double (*f)(), double a2); +extern int setcolrgam(double g); +extern int colrs_gambs(COLR *scan, int len); +extern int gambs_colrs(COLR *scan, int len); +extern void shiftcolrs(COLR *scan, int len, int adjust); +extern void normcolrs(COLR *scan, int len, int adjust); + +#endif + +#ifdef __cplusplus +} #endif