--- ray/src/common/color.h 2003/02/22 02:07:22 2.18
+++ ray/src/common/color.h 2013/02/04 03:42:13 2.32
@@ -1,73 +1,15 @@
-/* RCSid: $Id: color.h,v 2.18 2003/02/22 02:07:22 greg Exp $ */
+/* RCSid $Id: color.h,v 2.32 2013/02/04 03:42:13 greg Exp $ */
/*
* color.h - header for routines using pixel color values.
*
- * 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
* for speed. Stored color values use 4 bytes which contain
* three single byte mantissas and a common exponent.
*/
+#ifndef _RAD_COLOR_H_
+#define _RAD_COLOR_H_
-/* ====================================================================
- * The Radiance Software License, Version 1.0
- *
- * Copyright (c) 1990 - 2002 The Regents of the University of California,
- * through Lawrence Berkeley National Laboratory. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes Radiance software
- * (http://radsite.lbl.gov/)
- * developed by the Lawrence Berkeley National Laboratory
- * (http://www.lbl.gov/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
- * and "The Regents of the University of California" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact radiance@radsite.lbl.gov.
- *
- * 5. Products derived from this software may not be called "Radiance",
- * nor may "Radiance" appear in their name, without prior written
- * permission of Lawrence Berkeley National Laboratory.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of Lawrence Berkeley National Laboratory. For more
- * information on Lawrence Berkeley National Laboratory, please see
- * .
- */
-
-#include
#include
#ifdef __cplusplus
@@ -84,12 +26,13 @@ extern "C" {
#define COLXS 128 /* excess used for exponent */
#define WHT 3 /* used for RGBPRIMS type */
-#undef BYTE
-#define BYTE unsigned char /* 8-bit unsigned integer */
+#undef uby8
+#define uby8 unsigned char /* 8-bit unsigned integer */
-typedef BYTE COLR[4]; /* red, green, blue (or X,Y,Z), exponent */
+typedef uby8 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 */
@@ -169,7 +112,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))
@@ -213,12 +156,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, \
@@ -231,7 +174,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])
@@ -253,47 +196,9 @@ 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((char *)ms,(char *)md,sizeof(COLORMAT))
-#else
-#define cpcolormat(md,ms) memcpy((char *)md,(char *)ms,sizeof(COLORMAT))
-#endif
+#define cpcolormat(md,ms) memcpy((void *)md,(void *)ms,sizeof(COLORMAT))
-#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);
@@ -311,25 +216,27 @@ 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);
extern void shiftcolrs(COLR *scan, int len, int adjust);
extern void normcolrs(COLR *scan, int len, int adjust);
-#endif
#ifdef __cplusplus
}
#endif
+#endif /* _RAD_COLOR_H_ */
+