--- ray/src/common/colrops.c 1992/09/08 10:04:33 2.3 +++ ray/src/common/colrops.c 2003/07/30 10:11:06 2.11 @@ -1,30 +1,29 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: colrops.c,v 2.11 2003/07/30 10:11:06 schorsch Exp $"; #endif - /* * Integer operations on COLR scanlines */ -#include "color.h" +#include "copyright.h" -#define NULL 0 +#include +#include -extern char *bmalloc(); +#include "rtmisc.h" +#include "color.h" + #define MAXGSHIFT 31 /* maximum shift for gamma table */ static BYTE *g_mant = NULL, *g_nexp = NULL; static BYTE (*g_bval)[256] = NULL; -extern double pow(); - +int setcolrcor(f, a2) /* set brightness correction */ -double (*f)(); +double (*f)(double,double); double a2; { double mult; @@ -44,8 +43,9 @@ double a2; } +int setcolrinv(f, a2) /* set inverse brightness correction */ -double (*f)(); +double (*f)(double,double); double a2; { double mult; @@ -58,19 +58,18 @@ double a2; /* compute gamb -> colr mapping */ i = 0; mult = 256.0; - for (j = 255; j > 0; j--) { - while ((g_mant[j] = mult * (*f)(j/256.0, a2)) < 128) { + for (j = 256; j--; ) { + while ((g_mant[j] = mult * (*f)((j+.5)/256.0, a2)) < 128) { i++; mult *= 2.0; } g_nexp[j] = i; } - g_mant[0] = 0; - g_nexp[0] = COLXS; return(0); } +int setcolrgam(g) /* set gamma conversion */ double g; { @@ -80,6 +79,7 @@ double g; } +int colrs_gambs(scan, len) /* convert scanline of colrs to gamma bytes */ register COLR *scan; int len; @@ -129,13 +129,14 @@ int len; } +int gambs_colrs(scan, len) /* convert gamma bytes to colr scanline */ register COLR *scan; int len; { register int nexpo; - if (g_mant == NULL | g_nexp == NULL) + if ((g_mant == NULL) | (g_nexp == NULL)) return(-1); while (len-- > 0) { nexpo = g_nexp[scan[0][RED]]; @@ -165,6 +166,7 @@ int len; } +void shiftcolrs(scan, len, adjust) /* shift a scanline of colors by 2^adjust */ register COLR *scan; register int len; @@ -186,6 +188,7 @@ register int adjust; } +void normcolrs(scan, len, adjust) /* normalize a scanline of colrs */ register COLR *scan; int len;