--- ray/src/rt/colortab.c 1990/03/29 12:43:07 1.14 +++ ray/src/rt/colortab.c 1992/10/06 12:13:48 2.2 @@ -1,4 +1,4 @@ -/* Copyright (c) 1989 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -16,9 +16,9 @@ static char SCCSid[] = "$SunId$ LBL"; * distribution is correlated to the last. */ -#include "color.h" +#include "standard.h" -#define NULL 0 +#include "color.h" /* histogram resolution */ #define NRED 24 #define NGRN 32 @@ -33,7 +33,7 @@ static char SCCSid[] = "$SunId$ LBL"; (int)(colval(c,p)*256.) : 255 ] /* color partition tree */ #define CNODE short -#define set_branch(p,c) ((c)<<2|(p)) +#define set_branch(p,c) ((c)<<2|(p)) #define set_pval(pv) ((pv)<<2|3) #define is_branch(cn) (((cn)&3)!=3) #define is_pval(cn) (((cn)&3)==3) @@ -43,8 +43,8 @@ static char SCCSid[] = "$SunId$ LBL"; /* our color table */ static struct tabent { long sum[3]; /* sum of colors using this entry */ - long n; /* number of colors */ - short ent[3]; /* current table value */ + int n; /* number of colors */ + BYTE ent[3]; /* current table value */ } *clrtab = NULL; /* color cube partition */ static CNODE *ctree = NULL; @@ -111,7 +111,7 @@ int (*set_pixel)(); if (cv[prim(*tp)] < part(*tp)) tp += 1< MAXDST2) { clrtab[h].ent[RED] = r; - clrtab[h].ent[GRN] = g; /* reassign pixel */ + clrtab[h].ent[GRN] = g; /* reassign pixel */ clrtab[h].ent[BLU] = b; #ifdef DEBUG sprintf(errmsg, "pixel %d = (%d,%d,%d) (%d refs)\n", @@ -142,15 +142,14 @@ int (*set_pixel)(); make_gmap(gam) /* make gamma correction map */ -double gam; +double gam; { - extern double pow(); register int i; for (i = 0; i < 256; i++) clrmap[RED][i] = clrmap[GRN][i] = - clrmap[BLU][i] = 256.0 * pow(i/256.0, 1.0/gam); + clrmap[BLU][i] = 256.0 * pow((i+0.5)/256.0, 1.0/gam); }