ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/biq.c
Revision: 1.3
Committed: Mon Jul 24 10:49:58 1989 UTC (34 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +7 -5 lines
Log Message:
added temp variables for speed

File Contents

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