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.2 by greg, Tue Sep 12 13:04:18 1989 UTC vs.
Revision 2.3 by greg, Wed Jan 29 15:18:34 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  
18   #define  NCOLS          880             /* for wide carriage */
19  
# Line 38 | Line 39 | char  *fname;
39   {
40          FILE  *input;
41          int  xres, yres;
42 <        COLOR  scanline[NCOLS];
42 <        char  sbuf[256];
42 >        COLR  scanline[NCOLS];
43          int  i;
44  
45          if (fname == NULL) {
# Line 50 | Line 50 | char  *fname;
50                  return(-1);
51          }
52                                  /* discard header */
53 <        while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n')
54 <                ;
53 >        if (checkheader(input, COLRFMT, NULL) < 0) {
54 >                fprintf(stderr, "%s: not a Radiance picture\n", fname);
55 >                return(-1);
56 >        }
57                                  /* get picture dimensions */
58 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
58 >        if (fgetresolu(&xres, &yres, input) < 0) {
59                  fprintf(stderr, "%s: bad picture size\n", fname);
60                  return(-1);
61          }
# Line 63 | Line 65 | char  *fname;
65          }
66  
67          fputs("\033[6~\033[7z", stdout);
68 + #ifdef _IOLBF
69 +        stdout->_flag &= ~_IOLBF;
70 + #endif
71          
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, 0);
78                  plotscan(scanline, xres, i);
79          }
80  
# Line 81 | 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 107 | Line 113 | int  y;
113                  }
114                  putchar('\r');
115                  putchar('\n');
116 +                fflush(stdout);
117          }
118   }
119  
120  
121 < bit(col, x)                             /* return bit for color at x */
122 < COLOR  col;
121 > bit(clr, x)                             /* return bit for color at x */
122 > COLR  clr;
123   register int  x;
124   {
125 <        static float  cerr[NCOLS];
126 <        static double  err;
127 <        double  b;
125 >        static int  cerr[NCOLS];
126 >        static int  err;
127 >        int  b, errp;
128          register int  isblack;
129  
130 <        b = bright(col);
131 <        if (b > 1.0) b = 1.0;
130 >        b = normbright(clr);
131 >        errp = err;
132          err += b + cerr[x];
133 <        isblack = err < 0.5;
134 <        if (!isblack) err -= 1.0;
135 <        cerr[x] = err *= 0.5;
133 >        isblack = err < 128;
134 >        if (!isblack) err -= 256;
135 >        err /= 3;
136 >        cerr[x] = err + errp;
137          return(isblack);
138   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines