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

Comparing ray/src/px/mt160r.c (file contents):
Revision 1.7 by greg, Thu Apr 18 14:35:09 1991 UTC vs.
Revision 2.8 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1986 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  mt160r.c - program to dump pixel file to Mannesman-Tally 160.
6   *
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   */
9  
10   #include  <stdio.h>
11 + #include  <time.h>
12  
13 + #include  "platform.h"
14   #include  "color.h"
15 + #include  "resolu.h"
16  
17 < #define  NCOLS          880             /* for wide carriage */
17 > #define  NCOLS          880             /* for wide carriage */
18  
19 + static int printp(char  *fname);
20 + static void plotscan(COLR  scan[], int  len, int  y);
21 + static int bit(COLR  clr, int  x);
22  
23 < main(argc, argv)
24 < int  argc;
25 < char  *argv[];
23 >
24 > int
25 > main(
26 >        int  argc,
27 >        char  *argv[]
28 > )
29   {
30          int  i;
31          int  status = 0;
32 <        
32 >        SET_DEFAULT_BINARY();
33 >        SET_FILE_BINARY(stdin);
34 >        SET_FILE_BINARY(stdout);
35          if (argc < 2)
36                  status += printp(NULL) == -1;
37          else
# Line 33 | Line 41 | char  *argv[];
41   }
42  
43  
44 < printp(fname)                           /* print a picture */
45 < char  *fname;
44 > static int
45 > printp(                         /* print a picture */
46 >        char  *fname
47 > )
48   {
49          FILE  *input;
50          int  xres, yres;
51          COLR  scanline[NCOLS];
52          int  i;
53 <
53 >        
54          if (fname == NULL) {
55                  input = stdin;
56                  fname = "<stdin>";
# Line 54 | Line 64 | char  *fname;
64                  return(-1);
65          }
66                                  /* get picture dimensions */
67 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
67 >        if (fgetresolu(&xres, &yres, input) < 0) {
68                  fprintf(stderr, "%s: bad picture size\n", fname);
69                  return(-1);
70          }
# Line 82 | Line 92 | char  *fname;
92   }
93  
94  
95 < plotscan(scan, len, y)                  /* plot a scanline */
96 < COLR  scan[];
97 < int  len;
98 < int  y;
95 > static void
96 > plotscan(                       /* plot a scanline */
97 >        COLR  scan[],
98 >        int  len,
99 >        int  y
100 > )
101   {
102          static BYTE  pat[NCOLS];
103          int  bpos;
104          register int  i;
105  
106 <        if (bpos = y & 7) {
106 >        if ((bpos = y & 7)) {
107  
108                  for (i = 0; i < len; i++)
109                          pat[i] |= bit(scan[i], i) << bpos;
# Line 109 | Line 121 | int  y;
121                  }
122                  putchar('\r');
123                  putchar('\n');
124 +                fflush(stdout);
125          }
126   }
127  
128  
129 < bit(clr, x)                             /* return bit for color at x */
130 < COLR  clr;
131 < register int  x;
129 > static int
130 > bit(                            /* return bit for color at x */
131 >        COLR  clr,
132 >        register int  x
133 > )
134   {
135          static int  cerr[NCOLS];
136          static int  err;
137 <        int  b;
137 >        int  b, errp;
138          register int  isblack;
139  
140          b = normbright(clr);
141 +        errp = err;
142          err += b + cerr[x];
143          isblack = err < 128;
144          if (!isblack) err -= 256;
145 <        cerr[x] = err /= 2;
145 >        err /= 3;
146 >        cerr[x] = err + errp;
147          return(isblack);
148   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines