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.10 by greg, Thu Sep 13 09:46:00 1990 UTC vs.
Revision 1.15 by greg, Fri Dec 14 16:33:16 1990 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17   #include  "color.h"
18  
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 44 | Line 47 | double  spread = 1e-4;         /* spread for star points */
47  
48   char  *tfname = NULL;
49  
50 + char  *lampdat = "lamp.tab";    /* lamp data file */
51 +
52   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  xrad;                      /* x window size */
57   int  yrad;                      /* y window size */
# Line 66 | Line 72 | char  **argv;
72          extern long  ftell();
73          extern int  quit(), headline();
74          FILE  *fin;
75 +        float  *lampcolor;
76 +        char  *lamptype = NULL;
77          long  fpos;
78          double  outaspect = 0.0;
79          double  d;
# Line 103 | Line 111 | char  **argv;
111                                  } else
112                                          nrows = atoi(argv[i]);
113                                  break;
114 +                        case 'c':
115 +                                correctaspect = !correctaspect;
116 +                                break;
117                          case 'p':
118                                  i++;
119                                  outaspect = atof(argv[i]);
# Line 112 | Line 123 | char  **argv;
123                                          d = pow(2.0, atof(argv[i+1]));
124                                  else
125                                          d = atof(argv[i+1]);
126 +                                if (d < 1e-20 || d > 1e20) {
127 +                                        fprintf(stderr,
128 +                                                "%s: exposure out of range\n",
129 +                                                        argv[0]);
130 +                                        exit(1);
131 +                                }
132                                  switch (argv[i][2]) {
133                                  case '\0':
134                                          scalecolor(exposure, d);
# Line 130 | Line 147 | char  **argv;
147                                  }
148                                  i++;
149                                  break;
150 +                        case 'f':
151 +                                lampdat = argv[++i];
152 +                                break;
153 +                        case 't':
154 +                                lamptype = argv[++i];
155 +                                break;
156                          case '1':
157                                  singlepass = 1;
158                                  break;
# Line 163 | Line 186 | char  **argv;
186                          }
187                  else
188                          break;
189 <                        
189 >                                        /* get lamp data (if necessary) */
190 >        if (lamptype != NULL) {
191 >                if (loadlamps(lampdat) < 0)
192 >                        quit(1);
193 >                if ((lampcolor = matchlamp(lamptype)) == NULL) {
194 >                        fprintf(stderr, "%s: unknown lamp type\n", lamptype);
195 >                        quit(1);
196 >                }
197 >                colval(exposure,RED) /= lampcolor[0];
198 >                colval(exposure,GRN) /= lampcolor[1];
199 >                colval(exposure,BLU) /= lampcolor[2];
200 >                freelamps();
201 >        }
202 >                                        /* open input file */
203          if (i == argc) {
204                  if (singlepass)
205                          fin = stdin;
# Line 281 | Line 317 | FILE  *in;
317                          fprintf(stderr, "%s: warning - partial frame (%d%%)\n",
318                                          progname, 100*i/yres);
319                          yres = i;
320 +                        y_r = (double)nrows/yres;
321                          break;
322                  }
323                  pass1scan(scan, i);
# Line 337 | Line 374 | FILE  *in;
374  
375   scan2init()                     /* prepare scanline arrays */
376   {
377 +        COLOR   ctmp;
378          double  d;
379          register int  i;
380  
# Line 366 | Line 404 | scan2init()                    /* prepare scanline arrays */
404                  fprintf(stderr, "%s: out of memory\n", progname);
405                  quit(1);
406          }
407 <                                        /* record pixel aspect and exposure */
408 <        d = x_c / y_r;
409 <        if (d < .99 || d > 1.01)
410 <                fputaspect(d, stdout);
407 >                                        /* record pixel aspect ratio */
408 >        if (!correctaspect) {
409 >                d = x_c / y_r;
410 >                if (!FEQ(d,1.0))
411 >                        fputaspect(d, stdout);
412 >        }
413 >                                        /* record exposure */
414          d = bright(exposure);
415 <        if (d < .995 || d > 1.005)
415 >        if (!FEQ(d,1.0))
416                  fputexpos(d, stdout);
417 +                                        /* record color correction */
418 +        copycolor(ctmp, exposure);
419 +        scalecolor(ctmp, 1.0/d);
420 +        if (!FEQ(colval(ctmp,RED),colval(ctmp,GRN)) ||
421 +                        !FEQ(colval(ctmp,GRN),colval(ctmp,BLU)))
422 +                fputcolcor(ctmp, stdout);
423          printf("\n");
424 <        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */
424 >                                        /* write out resolution */
425 >        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout);
426   }
427  
428  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines