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.3 by greg, Tue Sep 12 13:04:16 1989 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:05:36 1991 UTC

# Line 99 | Line 99 | long  scanpos[NROWS];
99  
100   extern double  atof();
101   double  exposure = 1.0;
102 + int  wrong_fmt = 0;
103  
104  
105   main(argc, argv)
106   int  argc;
107   char  *argv[];
108   {
109 <        int  onintr();
109 <        double  atof();
109 >        int  onintr(), checkhead();
110          char  sbuf[256];
111          register int  i;
112          
# Line 141 | Line 141 | char  *argv[];
141                  quitmsg(errmsg);
142          }
143                                  /* get header */
144 <        while (fgets(sbuf, sizeof(sbuf), fin) != NULL && sbuf[0] != '\n')
145 <                if (!strncmp(sbuf, "EXPOSURE=", 9))
146 <                        exposure *= atof(sbuf+9);
147 <
144 >        getheader(fin, checkhead, NULL);
145 >        if (wrong_fmt)
146 >                quitmsg("input must be a Radiance picture");
147                                  /* get picture dimensions */
148 <        if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
148 >        if (fgetresolu(&xmax, &ymax, fin) < 0)
149                  quitmsg("bad picture size");
150          if (xmax > NCOLS || ymax > NROWS)
151                  quitmsg("resolution mismatch");
# Line 170 | Line 169 | userr:
169   }
170  
171  
172 + checkhead(line)                         /* deal with line from header */
173 + char  *line;
174 + {
175 +        char    fmt[32];
176 +
177 +        if (isexpos(line))
178 +                exposure *= exposval(line);
179 +        else if (isformat(line)) {
180 +                formatval(fmt, line);
181 +                wrong_fmt = strcmp(fmt, COLRFMT);
182 +        }
183 + }
184 +
185 +
186   init()                  /* initialize terminal */
187   {
188          struct sgttyb  flags;
# Line 311 | Line 324 | loopcom()                              /* print pixel values interactively */
324                                  break;
325                          case 'l':
326                          case 'L':
327 <                                printf("%-3gL", bright(cval)*683.0/exposure);
327 >                                printf("%-3gL", luminance(cval)/exposure);
328                                  break;
329                          case 'c':
330                          case 'C':
# Line 392 | Line 405 | picreadline3(y, l3)                    /* read in 3-byte scanline */
405   int  y;
406   register rgbpixel  *l3;
407   {
408 <        register BYTE   *l4;
409 <        register int    shift, c;
397 <        int     i;
398 <
408 >        register int    i;
409 >                                                        /* read scanline */
410          getscan(y);
411                                                          /* convert scanline */
412 <        for (l4=scanline[0], i=xmax; i--; l4+=4, l3++) {
413 <                shift = l4[EXP] - COLXS;
414 <                if (shift >= 8) {
415 <                        l3->r = l3->g = l3->b = 255;
416 <                } else if (shift <= -8) {
406 <                        l3->r = l3->g = l3->b = 0;
407 <                } else if (shift > 0) {
408 <                        c = l4[RED] << shift;
409 <                        l3->r = c > 255 ? 255 : c;
410 <                        c = l4[GRN] << shift;
411 <                        l3->g = c > 255 ? 255 : c;
412 <                        c = l4[BLU] << shift;
413 <                        l3->b = c > 255 ? 255 : c;
414 <                } else if (shift < 0) {
415 <                        l3->r = l4[RED] >> -shift;
416 <                        l3->g = l4[GRN] >> -shift;
417 <                        l3->b = l4[BLU] >> -shift;
418 <                } else {
419 <                        l3->r = l4[RED];
420 <                        l3->g = l4[GRN];
421 <                        l3->b = l4[BLU];
422 <                }
412 >        normcolrs(scanline, xmax, 0);
413 >        for (i = 0; i < xmax; i++) {
414 >                l3[i].r = scanline[i][RED];
415 >                l3[i].g = scanline[i][GRN];
416 >                l3[i].b = scanline[i][BLU];
417          }
418   }
419  
# Line 530 | Line 524 | colormap  map;
524          register int  i, val;
525  
526          for (i = 0; i < 256; i++) {
527 <                val = pow(i/256.0, 1.0/GAMMA) * 256.0;
527 >                val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0;
528                  map[0][i] = map[1][i] = map[2][i] = val;
529          }
530   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines