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.6 by greg, Sat Apr 29 09:22:54 1989 UTC vs.
Revision 1.13 by greg, Sat Dec 8 10:14:33 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "color.h"
18  
19
19   extern char  *malloc();
20 + extern float  *matchlamp();
21  
22   #define  CHECKRAD       1.5     /* radius to check for filtering */
23  
# Line 45 | Line 45 | double  spread = 1e-4;         /* spread for star points */
45  
46   char  *tfname = NULL;
47  
48 + char  *lampdat = "lamp.tab";    /* lamp data file */
49 +
50   int  xres, yres;                /* resolution of input */
51 + double  inpaspect = 1.0;        /* pixel aspect ratio of input */
52 + int  correctaspect = 0;         /* aspect ratio correction? */
53  
54   int  xrad;                      /* x window size */
55   int  yrad;                      /* y window size */
# Line 64 | Line 68 | char  **argv;
68          extern char  *mktemp();
69          extern double  atof(), pow();
70          extern long  ftell();
71 <        extern int  quit();
71 >        extern int  quit(), headline();
72          FILE  *fin;
73 +        float  *lampcolor;
74 +        char  *lamptype = NULL;
75          long  fpos;
76 +        double  outaspect = 0.0;
77          double  d;
78          int  i;
79  
# Line 102 | Line 109 | char  **argv;
109                                  } else
110                                          nrows = atoi(argv[i]);
111                                  break;
112 +                        case 'c':
113 +                                correctaspect = !correctaspect;
114 +                                break;
115 +                        case 'p':
116 +                                i++;
117 +                                outaspect = atof(argv[i]);
118 +                                break;
119                          case 'e':
120                                  if (argv[i+1][0] == '+' || argv[i+1][0] == '-')
121                                          d = pow(2.0, atof(argv[i+1]));
# Line 125 | Line 139 | char  **argv;
139                                  }
140                                  i++;
141                                  break;
142 +                        case 'f':
143 +                                lampdat = argv[++i];
144 +                                break;
145 +                        case 't':
146 +                                lamptype = argv[++i];
147 +                                break;
148                          case '1':
149                                  singlepass = 1;
150                                  break;
151                          case '2':
152                                  singlepass = 0;
153                                  break;
154 <                        case 'p':
154 >                        case 'n':
155                                  npts = atoi(argv[++i]) / 2;
156                                  break;
157                          case 's':
# Line 185 | Line 205 | char  **argv;
205                  fprintf(stderr, "%s: bad # file arguments\n", progname);
206                  quit(1);
207          }
208 <                                        /* copy header */
209 <        copyheader(fin, stdout);
208 >                                        /* get lamp data (if necessary) */
209 >        if (lamptype != NULL) {
210 >                if (loadlamps(lampdat) < 0)
211 >                        quit(1);
212 >                if ((lampcolor = matchlamp(lamptype)) == NULL) {
213 >                        fprintf(stderr, "%s: unknown lamp type\n", lamptype);
214 >                        quit(1);
215 >                }
216 >                colval(exposure,RED) /= lampcolor[0];
217 >                colval(exposure,GRN) /= lampcolor[1];
218 >                colval(exposure,BLU) /= lampcolor[2];
219 >                freelamps();
220 >        }
221 >                                        /* get header */
222 >        getheader(fin, headline);
223                                          /* add new header info. */
224          printargs(i, argv, stdout);
225                                          /* get picture size */
226 <        if (fscanf(fin, "-Y %d +X %d\n", &yres, &xres) != 2) {
226 >        if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
227                  fprintf(stderr, "%s: bad picture size\n", progname);
228                  quit(1);
229          }
230 <        if (ncols > 0)
231 <                x_c = (double)ncols/xres;
199 <        else
230 >                                        /* compute output resolution */
231 >        if (ncols <= 0)
232                  ncols = x_c*xres + .5;
233 <        if (nrows > 0)
202 <                y_r = (double)nrows/yres;
203 <        else
233 >        if (nrows <= 0)
234                  nrows = y_r*yres + .5;
235 +        if (outaspect > .01) {
236 +                d = inpaspect * yres/xres / outaspect;
237 +                if (d * ncols > nrows)
238 +                        ncols = nrows / d;
239 +                else
240 +                        nrows = ncols * d;
241 +        }
242 +        x_c = (double)ncols/xres;
243 +        y_r = (double)nrows/yres;
244  
245 <        if (singlepass) {
207 <                                        /* skip exposure, etc. */
245 >        if (singlepass) {               /* skip exposure, etc. */
246                  pass1default();
247                  pass2(fin);
248                  quit(0);
# Line 224 | Line 262 | char  **argv;
262   }
263  
264  
265 + headline(s)                             /* process line from header */
266 + char  *s;
267 + {
268 +        fputs(s, stdout);               /* copy to output */
269 +        if (isaspect(s))                /* get aspect ratio */
270 +                inpaspect *= aspectval(s);
271 + }
272 +
273 +
274   copyfile(in, out)                       /* copy a file */
275   register FILE  *in, *out;
276   {
# Line 262 | Line 309 | FILE  *in;
309                          fprintf(stderr, "%s: warning - partial frame (%d%%)\n",
310                                          progname, 100*i/yres);
311                          yres = i;
312 +                        y_r = (double)nrows/yres;
313                          break;
314                  }
315                  pass1scan(scan, i);
# Line 307 | Line 355 | FILE  *in;
355                          quit(1);
356                  }
357          }
358 +                                        /* skip leftovers */
359 +        while (yread < yres) {
360 +                if (freadscan(scanin[0], xres, in) < 0)
361 +                        break;
362 +                yread++;
363 +        }
364   }
365  
366  
367   scan2init()                     /* prepare scanline arrays */
368   {
369 <        double  e;
369 >        double  d;
370          register int  i;
371  
372          if (rad <= 0.0) {
# Line 341 | Line 395 | scan2init()                    /* prepare scanline arrays */
395                  fprintf(stderr, "%s: out of memory\n", progname);
396                  quit(1);
397          }
398 <        e = bright(exposure);
399 <        if (e < 1-1e-7 || e > 1+1e-7)           /* record exposure */
400 <                printf("EXPOSURE=%e\n", e);
398 >                                        /* record pixel aspect and exposure */
399 >        if (!correctaspect) {
400 >                d = x_c / y_r;
401 >                if (d < .99 || d > 1.01)
402 >                        fputaspect(d, stdout);
403 >        }
404 >        d = bright(exposure);
405 >        if (d < .995 || d > 1.005)
406 >                fputexpos(d, stdout);
407          printf("\n");
408 <        printf("-Y %d +X %d\n", nrows, ncols);  /* write picture size */
408 >        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */
409   }
410  
411  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines