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

Comparing ray/src/px/aedimage.c (file contents):
Revision 1.5 by greg, Fri Oct 20 20:35:57 1989 UTC vs.
Revision 2.5 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   *  aedimage.c - RADIANCE driver for AED 512 terminal.
6   *
# Line 13 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include  <stdio.h>
12  
13 + #include  <math.h>
14 +
15   #include  <signal.h>
16  
17   #include  <sys/ioctl.h>
# Line 97 | Line 96 | FILE  *fin;
96   extern long  ftell();
97   long  scanpos[NROWS];
98  
100 extern double  atof();
99   double  exposure = 1.0;
100 + int  wrong_fmt = 0;
101  
102  
103   main(argc, argv)
# Line 140 | Line 139 | char  *argv[];
139                  quitmsg(errmsg);
140          }
141                                  /* get header */
142 <        getheader(fin, checkhead);
142 >        getheader(fin, checkhead, NULL);
143 >        if (wrong_fmt)
144 >                quitmsg("input must be a Radiance picture");
145                                  /* get picture dimensions */
146 <        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
146 >        if (fgetresolu(&xmax, &ymax, fin) < 0)
147                  quitmsg("bad picture size");
148          if (xmax > NCOLS || ymax > NROWS)
149                  quitmsg("resolution mismatch");
# Line 166 | Line 167 | userr:
167   }
168  
169  
170 + int
171   checkhead(line)                         /* deal with line from header */
172   char  *line;
173   {
174 <        if (!strncmp(line, "EXPOSURE=", 9))
175 <                exposure *= atof(line+9);
174 >        char    fmt[32];
175 >
176 >        if (isexpos(line))
177 >                exposure *= exposval(line);
178 >        else if (isformat(line)) {
179 >                formatval(fmt, line);
180 >                wrong_fmt = strcmp(fmt, COLRFMT);
181 >        }
182 >        return(0);
183   }
184  
185  
# Line 235 | Line 244 | char  *err;
244   }
245  
246  
247 + void
248   eputs(s)
249   char  *s;
250   {
# Line 242 | Line 252 | char  *s;
252   }
253  
254  
255 + void
256   quit(status)
257   int  status;
258   {
# Line 315 | Line 326 | loopcom()                              /* print pixel values interactively */
326                                  break;
327                          case 'l':
328                          case 'L':
329 <                                printf("%-3gL", bright(cval)*683.0/exposure);
329 >                                printf("%-3gL", luminance(cval)/exposure);
330                                  break;
331                          case 'c':
332                          case 'C':
# Line 400 | Line 411 | register rgbpixel  *l3;
411                                                          /* read scanline */
412          getscan(y);
413                                                          /* convert scanline */
414 <        normcolrs(scanline, xmax);
414 >        normcolrs(scanline, xmax, 0);
415          for (i = 0; i < xmax; i++) {
416                  l3[i].r = scanline[i][RED];
417                  l3[i].g = scanline[i][GRN];
# Line 511 | Line 522 | int  offset[3];
522   picreadcm(map)                  /* do gamma correction */
523   colormap  map;
524   {
514        extern double  pow();
525          register int  i, val;
526  
527          for (i = 0; i < 256; i++) {
528 <                val = pow(i/256.0, 1.0/GAMMA) * 256.0;
528 >                val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0;
529                  map[0][i] = map[1][i] = map[2][i] = val;
530          }
531   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines