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.10 by greg, Thu Apr 18 14:35:11 1991 UTC vs.
Revision 2.3 by greg, Wed Jan 29 15:18:20 1992 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  
21 + #define  ASPECT         (120./144.)     /* pixel aspect ratio */
22 +
23 + #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
24 +
25   /*
26   *  Subtractive primaries are ordered:  Yellow, Magenta, Cyan.
27   */
# Line 32 | Line 36 | static char SCCSid[] = "$SunId$ LBL";
36  
37   long  lpat[NCOLS][3];
38  
39 + int  dofilter = 0;              /* filter through pfilt first? */
40  
41 +
42   main(argc, argv)
43   int  argc;
44   char  *argv[];
45   {
46          int  i, status = 0;
47          
48 +        if (argc > 1 && !strcmp(argv[1], "-p")) {
49 +                dofilter++;
50 +                argv++; argc--;
51 +        }
52          if (argc < 2)
53                  status = printp(NULL) == -1;
54          else
# Line 51 | Line 61 | char  *argv[];
61   printp(fname)                           /* print a picture */
62   char  *fname;
63   {
64 +        char  buf[64];
65          FILE  *input;
66          int  xres, yres;
67          COLR  scanline[NCOLS];
68          int  i;
69  
70 <        if (fname == NULL) {
70 >        if (dofilter) {
71 >                if (fname == NULL)
72 >                        fname = "";
73 >                sprintf(buf, FILTER, fname);
74 >                if ((input = popen(buf, "r")) == NULL) {
75 >                        fprintf(stderr, "Cannot execute: %s\n", buf);
76 >                        return(-1);
77 >                }
78 >                fname = buf;
79 >        } else if (fname == NULL) {
80                  input = stdin;
81                  fname = "<stdin>";
82          } else if ((input = fopen(fname, "r")) == NULL) {
# Line 69 | Line 89 | char  *fname;
89                  return(-1);
90          }
91                                  /* get picture dimensions */
92 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
92 >        if (fgetresolu(&xres, &yres, input) < 0) {
93                  fprintf(stderr, "%s: bad picture size\n", fname);
94                  return(-1);
95          }
# Line 81 | Line 101 | char  *fname;
101          fputs("\0333\042", stdout);
102                                  /* clear line buffer */
103          clearlbuf();
104 + #ifdef _IOLBF
105 +        stdout->_flag &= ~_IOLBF;
106 + #endif
107                                  /* put out scanlines */
108          for (i = yres-1; i >= 0; i--) {
109                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 93 | Line 116 | char  *fname;
116                                  /* advance page */
117          putchar('\f');
118          
119 <        fclose(input);
119 >        if (dofilter)
120 >                pclose(input);
121 >        else
122 >                fclose(input);
123  
124          return(0);
125   }
# Line 133 | Line 159 | int  y;
159                          putchar('\r');
160                  }
161                  putchar('\n');
162 +                fflush(stdout);
163          }
164   }
165  
# Line 144 | Line 171 | int  s;
171   {
172          static int  cerr[NCOLS][3];
173          static int  err[3];
174 <        int  b;
174 >        int  b, errp;
175          register int  a, ison;
176  
177          a = sub_add(s);                 /* use additive primary */
178          b = col[a];
179 +        errp = err[a];
180          err[a] += b + cerr[x][a];
181          ison = err[a] < 128;
182          if (!ison) err[a] -= 256;
183 <        cerr[x][a] = err[a] /= 2;
183 >        err[a] /= 3;
184 >        cerr[x][a] = err[a] + errp;
185          return(ison);
186   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines