ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/biq.c
(Generate patch)

Comparing ray/src/px/biq.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:49:06 1989 UTC vs.
Revision 2.5 by schorsch, Sun Mar 28 20:33:13 2004 UTC

# Line 1 | Line 1
1 /*
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
4 + /*
5   *  biq.c - simple greyscale quantization.
6   *
7   *      9/19/88
8   */
9  
10 + #include <string.h>
11 +
12 + #include "standard.h"
13   #include "ciq.h"
14  
15 + static void draw_grey(colormap ocm);
16  
17 < biq(dith,nw,synth,cm)
18 < int dith;               /* is dithering desired? 0=no, 1=yes */
19 < int nw;                 /* number of colors wanted in output image */
20 < int synth;              /* synthesize colormap? 0=no, 1=yes */
21 < colormap cm;            /* quantization colormap */
22 <                        /* read if synth=0; always written */
17 >
18 >
19 > void
20 > biq(
21 >        int dith,               /* is dithering desired? 0=no, 1=yes */
22 >        int nw,                 /* number of colors wanted in output image */
23 >        int synth,              /* synthesize colormap? 0=no, 1=yes */
24 >        colormap cm             /* quantization colormap */
25 > )                       /* read if synth=0; always written */
26   {
27      colormap ocm;
28  
# Line 29 | Line 35 | colormap cm;           /* quantization colormap */
35  
36      draw_grey(ocm);
37  
38 <    bcopy(color,cm,sizeof color);
38 >    memcpy((void *)cm,(void *)color,sizeof color);
39   }
40  
41   /*----------------------------------------------------------------------*/
42  
43 < draw_grey(ocm)
44 < colormap ocm;
43 > static void
44 > draw_grey(
45 >        colormap ocm
46 > )
47   {
48      register rgbpixel *linin;
49      register pixel *linout;
50 +    rgbpixel intmp;
51 +    int outtmp;
52      int y;
53      register int x;
54  
# Line 48 | Line 58 | colormap ocm;
58      for (y = 0; y < ymax; y++) {
59          picreadline3(y, linin);
60          for (x = 0; x < xmax; x++) {
61 <                linin[x].r = ocm[0][linin[x].r];
62 <                linin[x].g = ocm[1][linin[x].g];
63 <                linin[x].b = ocm[2][linin[x].b];
64 <                linout[x] = rgb_bright(&linin[x]);
65 <                linout[x] = (linout[x]*n+n/2)/256;
61 >                intmp.r = ocm[0][linin[x].r];
62 >                intmp.g = ocm[1][linin[x].g];
63 >                intmp.b = ocm[2][linin[x].b];
64 >                outtmp = rgb_bright(&intmp);
65 >                linout[x] = (outtmp*n+n/2)/256;
66          }
67          picwriteline(y, linout);
68      }
69 <    free((char *)linin);
70 <    free((char *)linout);
69 >    free((void *)linin);
70 >    free((void *)linout);
71   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines