--- ray/src/common/colrops.c 1992/10/02 16:00:51 2.4 +++ ray/src/common/colrops.c 2003/07/27 22:12:01 2.10 @@ -1,17 +1,16 @@ -/* 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.10 2003/07/27 22:12:01 schorsch Exp $"; #endif - /* * Integer operations on COLR scanlines */ +#include "copyright.h" + +#include +#include #include "color.h" -#define NULL 0 - extern char *bmalloc(); #define MAXGSHIFT 31 /* maximum shift for gamma table */ @@ -20,11 +19,8 @@ static BYTE *g_mant = NULL, *g_nexp = NULL; static BYTE (*g_bval)[256] = NULL; -#ifndef pow -extern double pow(); -#endif - +int setcolrcor(f, a2) /* set brightness correction */ double (*f)(); double a2; @@ -46,6 +42,7 @@ double a2; } +int setcolrinv(f, a2) /* set inverse brightness correction */ double (*f)(); double a2; @@ -60,19 +57,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; { @@ -82,6 +78,7 @@ double g; } +int colrs_gambs(scan, len) /* convert scanline of colrs to gamma bytes */ register COLR *scan; int len; @@ -131,13 +128,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]]; @@ -167,6 +165,7 @@ int len; } +void shiftcolrs(scan, len, adjust) /* shift a scanline of colors by 2^adjust */ register COLR *scan; register int len; @@ -188,6 +187,7 @@ register int adjust; } +void normcolrs(scan, len, adjust) /* normalize a scanline of colrs */ register COLR *scan; int len;