ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/biq.c
Revision: 2.2
Committed: Sat Feb 22 02:07:27 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.1: +3 -6 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

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((char *)color,(char *)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 }