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.4 by greg, Fri Oct 20 20:35:59 1989 UTC vs.
Revision 2.6 by greg, Sat Feb 22 02:07:27 2003 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 + #ifdef MSDOS
12 + #include  <fcntl.h>
13 + #endif
14 + #include  <time.h>
15  
16   #include  "color.h"
17 + #include  "resolu.h"
18  
19 < #define  NCOLS          880             /* for wide carriage */
19 > #define  NCOLS          880             /* for wide carriage */
20  
21  
22   main(argc, argv)
# Line 23 | Line 25 | char  *argv[];
25   {
26          int  i;
27          int  status = 0;
28 <        
28 > #ifdef MSDOS
29 >        extern int  _fmode;
30 >        _fmode = O_BINARY;
31 >        setmode(fileno(stdin), O_BINARY);
32 >        setmode(fileno(stdout), O_BINARY);
33 > #endif
34          if (argc < 2)
35                  status += printp(NULL) == -1;
36          else
# Line 39 | Line 46 | char  *fname;
46          FILE  *input;
47          int  xres, yres;
48          COLR  scanline[NCOLS];
42        char  sbuf[256];
49          int  i;
50 <
50 >        
51          if (fname == NULL) {
52                  input = stdin;
53                  fname = "<stdin>";
# Line 50 | Line 56 | char  *fname;
56                  return(-1);
57          }
58                                  /* discard header */
59 <        while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n')
60 <                ;
59 >        if (checkheader(input, COLRFMT, NULL) < 0) {
60 >                fprintf(stderr, "%s: not a Radiance picture\n", fname);
61 >                return(-1);
62 >        }
63                                  /* get picture dimensions */
64 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
64 >        if (fgetresolu(&xres, &yres, input) < 0) {
65                  fprintf(stderr, "%s: bad picture size\n", fname);
66                  return(-1);
67          }
# Line 69 | Line 77 | char  *fname;
77                          fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
78                          return(-1);
79                  }
80 <                normcolrs(scanline, xres);
80 >                normcolrs(scanline, xres, 0);
81                  plotscan(scanline, xres, i);
82          }
83  
# Line 108 | Line 116 | int  y;
116                  }
117                  putchar('\r');
118                  putchar('\n');
119 +                fflush(stdout);
120          }
121   }
122  
# Line 118 | Line 127 | register int  x;
127   {
128          static int  cerr[NCOLS];
129          static int  err;
130 <        int  b;
130 >        int  b, errp;
131          register int  isblack;
132  
133          b = normbright(clr);
134 +        errp = err;
135          err += b + cerr[x];
136          isblack = err < 128;
137          if (!isblack) err -= 256;
138 <        cerr[x] = err /= 2;
138 >        err /= 3;
139 >        cerr[x] = err + errp;
140          return(isblack);
141   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines