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.8 by greg, Fri Jan 26 08:17:33 1990 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:05:03 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13   #include  <stdio.h>
14  
15   #include  "color.h"
16 + #include  "resolu.h"
17  
17
18   #define  NROWS          1440            /* 10" at 144 dpi */
19   #define  NCOLS          960             /* 8" at 120 dpi */
20  
# 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 56 | Line 64 | char  *fname;
64                  return(-1);
65          }
66                                  /* discard header */
67 <        getheader(input, NULL);
67 >        if (checkheader(input, COLRFMT, NULL) < 0) {
68 >                fprintf(stderr, "%s: not a Radiance picture\n", fname);
69 >                return(-1);
70 >        }
71                                  /* get picture dimensions */
72 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
72 >        if (fgetresolu(&xres, &yres, input) < 0) {
73                  fprintf(stderr, "%s: bad picture size\n", fname);
74                  return(-1);
75          }
# Line 68 | Line 79 | char  *fname;
79          }
80                                  /* set line spacing (overlap for knitting) */
81          fputs("\0333\042", stdout);
82 +                                /* clear line buffer */
83 +        clearlbuf();
84                                  /* put out scanlines */
85          for (i = yres-1; i >= 0; i--) {
86                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 91 | Line 104 | COLR  scan[];
104   int  len;
105   int  y;
106   {
94        static long  pat[NCOLS][3];
107          int  bpos;
108          register long  c;
109          register int  i, j;
# Line 100 | Line 112 | int  y;
112  
113                  for (j = 0; j < 3; j++)
114                          for (i = 0; i < len; i++)
115 <                                pat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
115 >                                lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
116  
117          } else {
118  
# Line 111 | Line 123 | int  y;
123                          putchar(len & 255);
124                          putchar(len >> 8);
125                          for (i = 0; i < len; i++) {
126 <                                c = pat[i][j] | colbit(scan[i],i,j);
126 >                                c = lpat[i][j] | colbit(scan[i],i,j);
127                                                          /* repeat this row */
128 <                                pat[i][j] = (c & 1) << 23;
128 >                                lpat[i][j] = (c & 1) << 23;
129                                  putchar(c>>16);
130                                  putchar(c>>8 & 255);
131                                  putchar(c & 255);
# Line 131 | Line 143 | register int  x;
143   int  s;
144   {
145          static int  cerr[NCOLS][3];
146 <        static int  err[3];
146 >        static int  err[3], errp[3];
147          int  b;
148          register int  a, ison;
149  
150          a = sub_add(s);                 /* use additive primary */
151          b = col[a];
152 +        errp[a] = err[a];
153          err[a] += b + cerr[x][a];
154          ison = err[a] < 128;
155          if (!ison) err[a] -= 256;
156 <        cerr[x][a] = err[a] /= 2;
156 >        err[a] /= 3;
157 >        cerr[x][a] = err[a] + errp[a];
158          return(ison);
159   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines