--- ray/src/common/colrops.c 1992/09/08 10:04:33 2.3 +++ ray/src/common/colrops.c 2003/02/25 02:47:21 2.7 @@ -1,13 +1,13 @@ -/* 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.7 2003/02/25 02:47:21 greg Exp $"; #endif - /* * Integer operations on COLR scanlines */ +#include "copyright.h" + +#include #include "color.h" #define NULL 0 @@ -20,9 +20,8 @@ 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 a2; @@ -44,6 +43,7 @@ double a2; } +int setcolrinv(f, a2) /* set inverse brightness correction */ double (*f)(); double a2; @@ -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,6 +129,7 @@ int len; } +int gambs_colrs(scan, len) /* convert gamma bytes to colr scanline */ register COLR *scan; int len; @@ -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;