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.2 by greg, Fri Mar 10 10:20:07 1989 UTC vs.
Revision 1.8 by greg, Wed Nov 7 13:10:27 1990 UTC

# Line 105 | Line 105 | main(argc, argv)
105   int  argc;
106   char  *argv[];
107   {
108 <        int  onintr();
109 <        double  atof();
108 >        int  onintr(), checkhead();
109          char  sbuf[256];
110          register int  i;
111          
# Line 141 | Line 140 | char  *argv[];
140                  quitmsg(errmsg);
141          }
142                                  /* get header */
143 <        while (fgets(sbuf, sizeof(sbuf), fin) != NULL && sbuf[0] != '\n')
145 <                if (!strncmp(sbuf, "EXPOSURE=", 9))
146 <                        exposure *= atof(sbuf+9);
147 <
143 >        getheader(fin, checkhead);
144                                  /* get picture dimensions */
145 <        if (fgets(sbuf, sizeof(sbuf), fin) == NULL ||
150 <                        sscanf(sbuf, "-Y %d +X %d\n", &ymax, &xmax) != 2)
145 >        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
146                  quitmsg("bad picture size");
147          if (xmax > NCOLS || ymax > NROWS)
148                  quitmsg("resolution mismatch");
# Line 171 | Line 166 | userr:
166   }
167  
168  
169 + checkhead(line)                         /* deal with line from header */
170 + char  *line;
171 + {
172 +        if (isexpos(line))
173 +                exposure *= exposval(line);
174 + }
175 +
176 +
177   init()                  /* initialize terminal */
178   {
179          struct sgttyb  flags;
# Line 393 | Line 396 | picreadline3(y, l3)                    /* read in 3-byte scanline */
396   int  y;
397   register rgbpixel  *l3;
398   {
399 <        register BYTE   *l4;
400 <        register int    shift, c;
398 <        int     i;
399 <
399 >        register int    i;
400 >                                                        /* read scanline */
401          getscan(y);
402                                                          /* convert scanline */
403 <        for (l4=scanline[0], i=xmax; i--; l4+=4, l3++) {
404 <                shift = l4[EXP] - COLXS;
405 <                if (shift >= 8) {
406 <                        l3->r = l3->g = l3->b = 255;
407 <                } else if (shift <= -8) {
407 <                        l3->r = l3->g = l3->b = 0;
408 <                } else if (shift > 0) {
409 <                        c = l4[RED] << shift;
410 <                        l3->r = c > 255 ? 255 : c;
411 <                        c = l4[GRN] << shift;
412 <                        l3->g = c > 255 ? 255 : c;
413 <                        c = l4[BLU] << shift;
414 <                        l3->b = c > 255 ? 255 : c;
415 <                } else if (shift < 0) {
416 <                        l3->r = l4[RED] >> -shift;
417 <                        l3->g = l4[GRN] >> -shift;
418 <                        l3->b = l4[BLU] >> -shift;
419 <                } else {
420 <                        l3->r = l4[RED];
421 <                        l3->g = l4[GRN];
422 <                        l3->b = l4[BLU];
423 <                }
403 >        normcolrs(scanline, xmax, 0);
404 >        for (i = 0; i < xmax; i++) {
405 >                l3[i].r = scanline[i][RED];
406 >                l3[i].g = scanline[i][GRN];
407 >                l3[i].b = scanline[i][BLU];
408          }
409   }
410  
# Line 531 | Line 515 | colormap  map;
515          register int  i, val;
516  
517          for (i = 0; i < 256; i++) {
518 <                val = pow(i/256.0, 1.0/GAMMA) * 256.0;
518 >                val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0;
519                  map[0][i] = map[1][i] = map[2][i] = val;
520          }
521   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines