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

Comparing ray/src/px/oki20c.c (file contents):
Revision 1.4 by greg, Fri Oct 20 12:07:08 1989 UTC vs.
Revision 1.9 by greg, Tue Jul 10 09:07:48 1990 UTC

# Line 24 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24  
25   #define  sub_add(sub)   (2-(sub))       /* map subtractive to additive pri. */
26  
27 + #ifdef  BSD
28 + #define  clearlbuf()    bzero((char *)lpat, sizeof(lpat))
29 + #else
30 + #define  clearlbuf()    (void)memset((char *)lpat, 0, sizeof(lpat))
31 + #endif
32  
33 + long  lpat[NCOLS][3];
34 +
35 +
36   main(argc, argv)
37   int  argc;
38   char  *argv[];
# Line 45 | Line 53 | char  *fname;
53   {
54          FILE  *input;
55          int  xres, yres;
56 <        COLOR  scanline[NCOLS];
56 >        COLR  scanline[NCOLS];
57          int  i;
58  
59          if (fname == NULL) {
# Line 67 | Line 75 | char  *fname;
75                  return(-1);
76          }
77                                  /* set line spacing (overlap for knitting) */
78 <        fputs("\0333\036", stdout);
78 >        fputs("\0333\042", stdout);
79 >                                /* clear line buffer */
80 >        clearlbuf();
81                                  /* put out scanlines */
82          for (i = yres-1; i >= 0; i--) {
83 <                if (freadscan(scanline, xres, input) < 0) {
83 >                if (freadcolrs(scanline, xres, input) < 0) {
84                          fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
85                          return(-1);
86                  }
87 +                normcolrs(scanline, xres, 0);
88                  plotscan(scanline, xres, i);
89          }
90                                  /* advance page */
# Line 86 | Line 97 | char  *fname;
97  
98  
99   plotscan(scan, len, y)                  /* plot a scanline */
100 < COLOR  scan[];
100 > COLR  scan[];
101   int  len;
102   int  y;
103   {
93        static long  pat[NCOLS][3];
104          int  bpos;
105          register long  c;
106          register int  i, j;
107  
108 <        if (bpos = y % 20) {
108 >        if (bpos = y % 23) {
109  
110 <                if (y > 20 & bpos < 4)                  /* knit bits */
111 <                        for (j = 0; j < 3; j++)
112 <                                for (i = 0; i < len; i++)
103 <                                        pat[i][j] |= (long)colbit(scan[i],i,j)
104 <                                                << (i+j & 4 ? bpos+24 : bpos);
105 <                else
106 <                        for (j = 0; j < 3; j++)
107 <                                for (i = 0; i < len; i++)
108 <                                        pat[i][j] |= (long)colbit(scan[i],i,j)
109 <                                                        << bpos;
110 >                for (j = 0; j < 3; j++)
111 >                        for (i = 0; i < len; i++)
112 >                                lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
113  
114          } else {
115  
# Line 114 | Line 117 | int  y;
117  
118                  for (j = 0; j < 3; j++) {
119                          fputs("\033%O", stdout);
120 <                        putchar(len & 0xff);
120 >                        putchar(len & 255);
121                          putchar(len >> 8);
122                          for (i = 0; i < len; i++) {
123 <                                c = pat[i][j];
124 <                                pat[i][j] = c>>4 & 0xf00000;
125 <                                if (i+j & 4)            /* knit last bit */
126 <                                        pat[i][j] |= colbit(scan[i],i,j) << 20;
127 <                                else
128 <                                        c |= colbit(scan[i],i,j);
126 <                                putchar(c>>16 & 0xff);
127 <                                putchar(c>>8 & 0xff);
128 <                                putchar(c & 0xff);
123 >                                c = lpat[i][j] | colbit(scan[i],i,j);
124 >                                                        /* repeat this row */
125 >                                lpat[i][j] = (c & 1) << 23;
126 >                                putchar(c>>16);
127 >                                putchar(c>>8 & 255);
128 >                                putchar(c & 255);
129                          }
130                          putchar('\r');
131                  }
# Line 135 | Line 135 | int  y;
135  
136  
137   colbit(col, x, s)               /* determine bit value for primary at x */
138 < COLOR  col;
138 > COLR  col;
139   register int  x;
140   int  s;
141   {
142 <        static float  cerr[NCOLS][3];
143 <        static double  err[3];
144 <        double  b;
142 >        static int  cerr[NCOLS][3];
143 >        static int  err[3];
144 >        int  b;
145          register int  a, ison;
146  
147          a = sub_add(s);                 /* use additive primary */
148 <        b = colval(col,a);
149 <        if (b > 1.0) b = 1.0;
148 >        b = col[a];
149          err[a] += b + cerr[x][a];
150 <        ison = err[a] < 0.5;
151 <        if (!ison) err[a] -= 1.0;
152 <        cerr[x][a] = err[a] *= 0.5;
150 >        ison = err[a] < 128;
151 >        if (!ison) err[a] -= 256;
152 >        cerr[x][a] = err[a] /= 2;
153          return(ison);
154   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines