ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/biq.c
Revision: 2.3
Committed: Tue May 13 17:58:33 2003 UTC (20 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +1 -1 lines
Log Message:
Changed (char *) casts for memory copies to (void *) and other fixes

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * biq.c - simple greyscale quantization.
6 *
7 * 9/19/88
8 */
9
10 #include "standard.h"
11 #include "ciq.h"
12
13
14 biq(dith,nw,synth,cm)
15 int dith; /* is dithering desired? 0=no, 1=yes */
16 int nw; /* number of colors wanted in output image */
17 int synth; /* synthesize colormap? 0=no, 1=yes */
18 colormap cm; /* quantization colormap */
19 /* read if synth=0; always written */
20 {
21 colormap ocm;
22
23 picreadcm(ocm); /* read original picture's colormap (usually identity)*/
24
25 for (n = 0; n < nw; n++) /* also sets n to nw */
26 color[0][n] = color[1][n] = color[2][n] = (n*256L+128)/nw;
27
28 picwritecm(color);
29
30 draw_grey(ocm);
31
32 bcopy((void *)color,(void *)cm,sizeof color);
33 }
34
35 /*----------------------------------------------------------------------*/
36
37 draw_grey(ocm)
38 colormap ocm;
39 {
40 register rgbpixel *linin;
41 register pixel *linout;
42 rgbpixel intmp;
43 int outtmp;
44 int y;
45 register int x;
46
47 linin = line3alloc(xmax);
48 linout = linealloc(xmax);
49
50 for (y = 0; y < ymax; y++) {
51 picreadline3(y, linin);
52 for (x = 0; x < xmax; x++) {
53 intmp.r = ocm[0][linin[x].r];
54 intmp.g = ocm[1][linin[x].g];
55 intmp.b = ocm[2][linin[x].b];
56 outtmp = rgb_bright(&intmp);
57 linout[x] = (outtmp*n+n/2)/256;
58 }
59 picwriteline(y, linout);
60 }
61 free((void *)linin);
62 free((void *)linout);
63 }