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.6 by greg, Fri Oct 20 16:44:34 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 +                normscan(scanline, xres);
78                  plotscan(scanline, xres, i);
79          }
80                                  /* advance page */
# Line 85 | Line 86 | char  *fname;
86   }
87  
88  
89 + normscan(scan, len)                     /* normalize a scanline */
90 + register COLR  scan[];
91 + int  len;
92 + {
93 +        register int  i;
94 +
95 +        for (i = 0; i < len; i++)
96 +                colr_norm(scan[i], scan[i]);
97 + }
98 +
99 +
100   plotscan(scan, len, y)                  /* plot a scanline */
101 < COLOR  scan[];
101 > COLR  scan[];
102   int  len;
103   int  y;
104   {
# Line 95 | Line 107 | int  y;
107          register long  c;
108          register int  i, j;
109  
110 <        if (bpos = y % 20) {
110 >        if (bpos = y % 23) {
111  
112 <                if (y > 20 & bpos < 4)                  /* knit bits */
113 <                        for (j = 0; j < 3; j++)
114 <                                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;
112 >                for (j = 0; j < 3; j++)
113 >                        for (i = 0; i < len; i++)
114 >                                pat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
115  
116          } else {
117  
# Line 114 | Line 119 | int  y;
119  
120                  for (j = 0; j < 3; j++) {
121                          fputs("\033%O", stdout);
122 <                        putchar(len & 0xff);
122 >                        putchar(len & 255);
123                          putchar(len >> 8);
124                          for (i = 0; i < len; i++) {
125 <                                c = pat[i][j];
126 <                                pat[i][j] = c>>4 & 0xf00000;
127 <                                if (i+j & 4)            /* knit last bit */
128 <                                        pat[i][j] |= colbit(scan[i],i,j) << 20;
129 <                                else
130 <                                        c |= colbit(scan[i],i,j);
126 <                                putchar(c>>16 & 0xff);
127 <                                putchar(c>>8 & 0xff);
128 <                                putchar(c & 0xff);
125 >                                c = pat[i][j] | colbit(scan[i],i,j);
126 >                                                        /* repeat this row */
127 >                                pat[i][j] = (c & 1) << 23;
128 >                                putchar(c>>16);
129 >                                putchar(c>>8 & 255);
130 >                                putchar(c & 255);
131                          }
132                          putchar('\r');
133                  }
# Line 135 | Line 137 | int  y;
137  
138  
139   colbit(col, x, s)               /* determine bit value for primary at x */
140 < COLOR  col;
140 > COLR  col;
141   register int  x;
142   int  s;
143   {
144 <        static float  cerr[NCOLS][3];
145 <        static double  err[3];
146 <        double  b;
144 >        static int  cerr[NCOLS][3];
145 >        static int  err[3];
146 >        int  b;
147          register int  a, ison;
148  
149          a = sub_add(s);                 /* use additive primary */
150 <        b = colval(col,a);
149 <        if (b > 1.0) b = 1.0;
150 >        b = col[a];
151          err[a] += b + cerr[x][a];
152 <        ison = err[a] < 0.5;
153 <        if (!ison) err[a] -= 1.0;
154 <        cerr[x][a] = err[a] *= 0.5;
152 >        ison = err[a] < 128;
153 >        if (!ison) err[a] -= 256;
154 >        cerr[x][a] = err[a] /= 2;
155          return(ison);
156   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines