--- ray/src/px/clrtab.c 1993/12/09 11:57:15 2.8 +++ ray/src/px/clrtab.c 2003/05/13 17:58:33 2.14 @@ -1,9 +1,6 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: clrtab.c,v 2.14 2003/05/13 17:58:33 greg Exp $"; #endif - /* * Simple median-cut color quantization based on colortab.c */ @@ -23,7 +20,7 @@ static char SCCSid[] = "$SunId$ LBL"; #define part(cn) ((cn)>>2) #define prim(cn) ((cn)&3) /* our color table (global) */ -BYTE clrtab[256][3]; +extern BYTE clrtab[256][3]; /* histogram of colors / color assignments */ static unsigned histo[NRED][NGRN][NBLU]; #define cndx(c) histo[((c)[RED]*NRED)>>8][((c)[GRN]*NGRN)>>8][((c)[BLU]*NBLU)>>8] @@ -40,10 +37,16 @@ static int CLRCUBE[3][2] = {0,NRED,0,NGRN,0,NBLU}; #endif #endif +static cut(), mktabent(), closest(), addneigh(), setclosest(); +static int split(); +static unsigned dist(); -new_histo() /* clear our histogram */ + +new_histo(n) /* clear our histogram */ +int n; { - bzero((char *)histo, sizeof(histo)); + bzero((void *)histo, sizeof(histo)); + return(0); } @@ -77,6 +80,8 @@ int ncolors; #ifdef CLOSEST closest(ncolors); /* ensure colors picked are closest */ #endif + /* reset dithering function */ + dith_colrs((BYTE *)NULL, (COLR *)NULL, 0); /* return new color table size */ return(ncolors); } @@ -114,7 +119,7 @@ int n; if (n != N) { /* get error propogation array */ if (N) { - free((char *)cerr); + free((void *)cerr); cerr = NULL; } if (n) @@ -125,7 +130,7 @@ int n; return; } N = n; - bzero((char *)cerr, 3*N*sizeof(short)); + bzero((void *)cerr, 3*N*sizeof(short)); } err[0] = err[1] = err[2] = 0; for (x = 0; x < n; x++) { @@ -164,7 +169,7 @@ int c0, c1; } /* split box */ branch = split(box); - bcopy((char *)box, (char *)kb, sizeof(kb)); + bcopy((void *)box, (void *)kb, sizeof(kb)); /* do left (lesser) branch */ kb[prim(branch)][1] = part(branch); cut(kb, c0, (c0+c1)>>1); @@ -332,7 +337,8 @@ int j; if (nl[i][t] == i) { /* add to list */ nl[i][t++] = j; if (t % NBSIZ == 0) { /* enlarge list */ - if ((nnl = realloc(nl[i], t+NBSIZ)) == NULL) + if ((nnl = realloc((void *)nl[i], + t+NBSIZ)) == NULL) t--; else nl[i] = (BYTE *)nnl;