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

Comparing ray/src/px/paintjet.c (file contents):
Revision 1.1 by greg, Fri Oct 6 13:50:58 1989 UTC vs.
Revision 2.3 by greg, Mon Sep 21 12:13:43 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1989 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   */
12  
13   #include  <stdio.h>
14 + #ifdef MSDOS
15 + #include  <fcntl.h>
16 + #endif
17  
18   #include  "color.h"
19 + #include  "resolu.h"
20  
21 < #define  NCOLS          1440            /* 8" at 180 dpi */
21 > #define  NCOLS          1440            /* 8" at 180 dpi */
22  
23  
24   main(argc, argv)
# Line 22 | Line 26 | int  argc;
26   char  *argv[];
27   {
28          int  i, status = 0;
29 <        
29 > #ifdef MSDOS
30 >        extern int  _fmode;
31 >        _fmode = O_BINARY;
32 >        setmode(fileno(stdin), O_BINARY);
33 >        setmode(fileno(stdout), O_BINARY);
34 > #endif
35          if (argc < 2)
36                  status = printp(NULL) == -1;
37          else
# Line 37 | Line 46 | char  *fname;
46   {
47          FILE  *input;
48          int  xres, yres;
49 <        COLOR  scanline[NCOLS];
49 >        COLR  scanline[NCOLS];
50          int  i;
51  
52          if (fname == NULL) {
# Line 48 | Line 57 | char  *fname;
57                  return(-1);
58          }
59                                  /* discard header */
60 <        getheader(input, NULL);
60 >        if (checkheader(input, COLRFMT, NULL) < 0) {
61 >                fprintf(stderr, "%s: not a Radiance picture\n", fname);
62 >                return(-1);
63 >        }
64                                  /* get picture dimensions */
65 <        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
65 >        if (fgetresolu(&xres, &yres, input) < 0) {
66                  fprintf(stderr, "%s: bad picture size\n", fname);
67                  return(-1);
68          }
# Line 65 | Line 77 | char  *fname;
77                          ((NCOLS-xres)>>4)<<5, xres);
78          
79          for (i = yres-1; i >= 0; i--) {
80 <                if (freadscan(scanline, xres, input) < 0)
80 >                if (freadcolrs(scanline, xres, input) < 0)
81                          return(-1);
82 +                normcolrs(scanline, xres, 0);
83                  plotscan(scanline, xres, i);
84          }
85  
# Line 79 | Line 92 | char  *fname;
92  
93  
94   plotscan(scan, len, y)                  /* plot a scanline */
95 < COLOR  scan[];
95 > COLR  scan[];
96   int  len;
97   int  y;
98   {
# Line 103 | Line 116 | int  y;
116  
117  
118   colbit(col, x, a)               /* determine bit value for primary at x */
119 < COLOR  col;
119 > COLR  col;
120   register int  x;
121   register int  a;
122   {
123 <        static float  cerr[NCOLS][3];
124 <        static double  err[3];
125 <        double  b;
123 >        static int  cerr[NCOLS][3];
124 >        static int  err[3];
125 >        int  b, errp;
126          register int  ison;
127  
128 <        b = colval(col,a);
129 <        if (b > 1.0) b = 1.0;
128 >        b = col[a];
129 >        errp = err[a];
130          err[a] += b + cerr[x][a];
131 <        ison = err[a] > 0.5;
132 <        if (ison) err[a] -= 1.0;
133 <        cerr[x][a] = err[a] *= 0.5;
131 >        ison = err[a] > 128;
132 >        if (ison) err[a] -= 256;
133 >        err[a] /= 3;
134 >        cerr[x][a] = err[a] + errp;
135          return(ison);
136   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines