--- ray/src/px/biq.c 1989/02/02 10:49:06 1.1 +++ ray/src/px/biq.c 2004/03/28 20:33:13 2.5 @@ -1,22 +1,28 @@ -/* - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: biq.c,v 2.5 2004/03/28 20:33:13 schorsch Exp $"; #endif +/* * biq.c - simple greyscale quantization. * * 9/19/88 */ +#include + +#include "standard.h" #include "ciq.h" +static void draw_grey(colormap ocm); -biq(dith,nw,synth,cm) -int dith; /* is dithering desired? 0=no, 1=yes */ -int nw; /* number of colors wanted in output image */ -int synth; /* synthesize colormap? 0=no, 1=yes */ -colormap cm; /* quantization colormap */ - /* read if synth=0; always written */ + + +void +biq( + int dith, /* is dithering desired? 0=no, 1=yes */ + int nw, /* number of colors wanted in output image */ + int synth, /* synthesize colormap? 0=no, 1=yes */ + colormap cm /* quantization colormap */ +) /* read if synth=0; always written */ { colormap ocm; @@ -29,16 +35,20 @@ colormap cm; /* quantization colormap */ draw_grey(ocm); - bcopy(color,cm,sizeof color); + memcpy((void *)cm,(void *)color,sizeof color); } /*----------------------------------------------------------------------*/ -draw_grey(ocm) -colormap ocm; +static void +draw_grey( + colormap ocm +) { register rgbpixel *linin; register pixel *linout; + rgbpixel intmp; + int outtmp; int y; register int x; @@ -48,14 +58,14 @@ colormap ocm; for (y = 0; y < ymax; y++) { picreadline3(y, linin); for (x = 0; x < xmax; x++) { - linin[x].r = ocm[0][linin[x].r]; - linin[x].g = ocm[1][linin[x].g]; - linin[x].b = ocm[2][linin[x].b]; - linout[x] = rgb_bright(&linin[x]); - linout[x] = (linout[x]*n+n/2)/256; + intmp.r = ocm[0][linin[x].r]; + intmp.g = ocm[1][linin[x].g]; + intmp.b = ocm[2][linin[x].b]; + outtmp = rgb_bright(&intmp); + linout[x] = (outtmp*n+n/2)/256; } picwriteline(y, linout); } - free((char *)linin); - free((char *)linout); + free((void *)linin); + free((void *)linout); }