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

Comparing ray/src/px/pfilt.c (file contents):
Revision 1.14 by greg, Sat Dec 8 13:23:47 1990 UTC vs.
Revision 1.16 by greg, Thu Apr 18 14:35:21 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   extern char  *malloc();
20   extern float  *matchlamp();
21  
22 + #define  FEQ(a,b)       ((a) >= .98*(b) && (a) <= 1.02*(b))
23 +
24   #define  CHECKRAD       1.5     /* radius to check for filtering */
25  
26   COLOR  exposure = WHTCOLOR;     /* exposure for the frame */
# Line 51 | Line 53 | int  xres, yres;               /* resolution of input */
53   double  inpaspect = 1.0;        /* pixel aspect ratio of input */
54   int  correctaspect = 0;         /* aspect ratio correction? */
55  
56 + int  wrongformat = 0;
57 +
58   int  xrad;                      /* x window size */
59   int  yrad;                      /* y window size */
60  
# Line 121 | Line 125 | char  **argv;
125                                          d = pow(2.0, atof(argv[i+1]));
126                                  else
127                                          d = atof(argv[i+1]);
128 +                                if (d < 1e-20 || d > 1e20) {
129 +                                        fprintf(stderr,
130 +                                                "%s: exposure out of range\n",
131 +                                                        argv[0]);
132 +                                        exit(1);
133 +                                }
134                                  switch (argv[i][2]) {
135                                  case '\0':
136                                          scalecolor(exposure, d);
# Line 219 | Line 229 | char  **argv;
229                  quit(1);
230          }
231                                          /* get header */
232 <        getheader(fin, headline);
232 >        getheader(fin, headline, NULL);
233 >        if (wrongformat) {
234 >                fprintf(stderr, "%s: input must be a Radiance picture\n",
235 >                                progname);
236 >                quit(1);
237 >        }
238                                          /* add new header info. */
239          printargs(i, argv, stdout);
240                                          /* get picture size */
# Line 265 | Line 280 | char  **argv;
280   headline(s)                             /* process line from header */
281   char  *s;
282   {
283 +        char  fmt[32];
284 +
285          fputs(s, stdout);               /* copy to output */
286          if (isaspect(s))                /* get aspect ratio */
287                  inpaspect *= aspectval(s);
288 +        else if (isformat(s)) {
289 +                formatval(fmt, s);
290 +                wrongformat = strcmp(fmt, COLRFMT);
291 +        }
292   }
293  
294  
# Line 366 | Line 387 | FILE  *in;
387  
388   scan2init()                     /* prepare scanline arrays */
389   {
390 +        COLOR   ctmp;
391          double  d;
392          register int  i;
393  
# Line 395 | Line 417 | scan2init()                    /* prepare scanline arrays */
417                  fprintf(stderr, "%s: out of memory\n", progname);
418                  quit(1);
419          }
420 <                                        /* record pixel aspect and exposure */
420 >                                        /* record pixel aspect ratio */
421          if (!correctaspect) {
422                  d = x_c / y_r;
423 <                if (d < .99 || d > 1.01)
423 >                if (!FEQ(d,1.0))
424                          fputaspect(d, stdout);
425          }
426 +                                        /* record exposure */
427          d = bright(exposure);
428 <        if (d < .995 || d > 1.005)
428 >        if (!FEQ(d,1.0))
429                  fputexpos(d, stdout);
430 +                                        /* record color correction */
431 +        copycolor(ctmp, exposure);
432 +        scalecolor(ctmp, 1.0/d);
433 +        if (!FEQ(colval(ctmp,RED),colval(ctmp,GRN)) ||
434 +                        !FEQ(colval(ctmp,GRN),colval(ctmp,BLU)))
435 +                fputcolcor(ctmp, stdout);
436          printf("\n");
437 <        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */
437 >                                        /* write out resolution */
438 >        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout);
439   }
440  
441  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines