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.7 by greg, Fri Oct 20 20:36:02 1989 UTC

# Line 45 | Line 45 | char  *fname;
45   {
46          FILE  *input;
47          int  xres, yres;
48 <        COLOR  scanline[NCOLS];
48 >        COLR  scanline[NCOLS];
49          int  i;
50  
51          if (fname == NULL) {
# Line 67 | Line 67 | char  *fname;
67                  return(-1);
68          }
69                                  /* set line spacing (overlap for knitting) */
70 <        fputs("\0333\036", stdout);
70 >        fputs("\0333\042", stdout);
71                                  /* put out scanlines */
72          for (i = yres-1; i >= 0; i--) {
73 <                if (freadscan(scanline, xres, input) < 0) {
73 >                if (freadcolrs(scanline, xres, input) < 0) {
74                          fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
75                          return(-1);
76                  }
77 +                normcolrs(scanline, xres);
78                  plotscan(scanline, xres, i);
79          }
80                                  /* advance page */
# Line 86 | Line 87 | char  *fname;
87  
88  
89   plotscan(scan, len, y)                  /* plot a scanline */
90 < COLOR  scan[];
90 > COLR  scan[];
91   int  len;
92   int  y;
93   {
# Line 95 | Line 96 | int  y;
96          register long  c;
97          register int  i, j;
98  
99 <        if (bpos = y % 20) {
99 >        if (bpos = y % 23) {
100  
101 <                if (y > 20 & bpos < 4)                  /* knit bits */
102 <                        for (j = 0; j < 3; j++)
103 <                                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;
101 >                for (j = 0; j < 3; j++)
102 >                        for (i = 0; i < len; i++)
103 >                                pat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
104  
105          } else {
106  
# Line 114 | Line 108 | int  y;
108  
109                  for (j = 0; j < 3; j++) {
110                          fputs("\033%O", stdout);
111 <                        putchar(len & 0xff);
111 >                        putchar(len & 255);
112                          putchar(len >> 8);
113                          for (i = 0; i < len; i++) {
114 <                                c = pat[i][j];
115 <                                pat[i][j] = c>>4 & 0xf00000;
116 <                                if (i+j & 4)            /* knit last bit */
117 <                                        pat[i][j] |= colbit(scan[i],i,j) << 20;
118 <                                else
119 <                                        c |= colbit(scan[i],i,j);
126 <                                putchar(c>>16 & 0xff);
127 <                                putchar(c>>8 & 0xff);
128 <                                putchar(c & 0xff);
114 >                                c = pat[i][j] | colbit(scan[i],i,j);
115 >                                                        /* repeat this row */
116 >                                pat[i][j] = (c & 1) << 23;
117 >                                putchar(c>>16);
118 >                                putchar(c>>8 & 255);
119 >                                putchar(c & 255);
120                          }
121                          putchar('\r');
122                  }
# Line 135 | Line 126 | int  y;
126  
127  
128   colbit(col, x, s)               /* determine bit value for primary at x */
129 < COLOR  col;
129 > COLR  col;
130   register int  x;
131   int  s;
132   {
133 <        static float  cerr[NCOLS][3];
134 <        static double  err[3];
135 <        double  b;
133 >        static int  cerr[NCOLS][3];
134 >        static int  err[3];
135 >        int  b;
136          register int  a, ison;
137  
138          a = sub_add(s);                 /* use additive primary */
139 <        b = colval(col,a);
149 <        if (b > 1.0) b = 1.0;
139 >        b = col[a];
140          err[a] += b + cerr[x][a];
141 <        ison = err[a] < 0.5;
142 <        if (!ison) err[a] -= 1.0;
143 <        cerr[x][a] = err[a] *= 0.5;
141 >        ison = err[a] < 128;
142 >        if (!ison) err[a] -= 256;
143 >        cerr[x][a] = err[a] /= 2;
144          return(ison);
145   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines