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.8 by greg, Fri Jan 5 17:52:52 1990 UTC vs.
Revision 1.9 by greg, Tue Jan 9 17:58:35 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "color.h"
18  
19
19   extern char  *malloc();
20  
21   #define  CHECKRAD       1.5     /* radius to check for filtering */
# Line 46 | Line 45 | double  spread = 1e-4;         /* spread for star points */
45   char  *tfname = NULL;
46  
47   int  xres, yres;                /* resolution of input */
48 + double  inpaspect = 1.0;        /* pixel aspect ratio of input */
49  
50   int  xrad;                      /* x window size */
51   int  yrad;                      /* y window size */
# Line 64 | Line 64 | char  **argv;
64          extern char  *mktemp();
65          extern double  atof(), pow();
66          extern long  ftell();
67 <        extern int  quit();
67 >        extern int  quit(), headline();
68          FILE  *fin;
69          long  fpos;
70 +        double  outaspect = 0.0;
71          double  d;
72          int  i;
73  
# Line 102 | Line 103 | char  **argv;
103                                  } else
104                                          nrows = atoi(argv[i]);
105                                  break;
106 +                        case 'p':
107 +                                i++;
108 +                                outaspect = atof(argv[i]);
109 +                                break;
110                          case 'e':
111                                  if (argv[i+1][0] == '+' || argv[i+1][0] == '-')
112                                          d = pow(2.0, atof(argv[i+1]));
# Line 131 | Line 136 | char  **argv;
136                          case '2':
137                                  singlepass = 0;
138                                  break;
139 <                        case 'p':
139 >                        case 'n':
140                                  npts = atoi(argv[++i]) / 2;
141                                  break;
142                          case 's':
# Line 185 | Line 190 | char  **argv;
190                  fprintf(stderr, "%s: bad # file arguments\n", progname);
191                  quit(1);
192          }
193 <                                        /* copy header */
194 <        copyheader(fin, stdout);
193 >                                        /* get header */
194 >        getheader(fin, headline);
195                                          /* add new header info. */
196          printargs(i, argv, stdout);
197                                          /* get picture size */
# Line 194 | Line 199 | char  **argv;
199                  fprintf(stderr, "%s: bad picture size\n", progname);
200                  quit(1);
201          }
202 <        if (ncols > 0)
203 <                x_c = (double)ncols/xres;
199 <        else
202 >                                        /* compute output resolution */
203 >        if (ncols <= 0)
204                  ncols = x_c*xres + .5;
205 <        if (nrows > 0)
202 <                y_r = (double)nrows/yres;
203 <        else
205 >        if (nrows <= 0)
206                  nrows = y_r*yres + .5;
207 +        if (outaspect > .01) {
208 +                d = inpaspect * yres/xres / outaspect;
209 +                if (d * ncols > nrows)
210 +                        ncols = nrows / d;
211 +                else
212 +                        nrows = ncols * d;
213 +        }
214 +        x_c = (double)ncols/xres;
215 +        y_r = (double)nrows/yres;
216  
217 <        if (singlepass) {
207 <                                        /* skip exposure, etc. */
217 >        if (singlepass) {               /* skip exposure, etc. */
218                  pass1default();
219                  pass2(fin);
220                  quit(0);
# Line 224 | Line 234 | char  **argv;
234   }
235  
236  
237 + headline(s)                             /* process line from header */
238 + char  *s;
239 + {
240 +        fputs(s, stdout);               /* copy to output */
241 +        if (isaspect(s))                /* get aspect ratio */
242 +                inpaspect *= aspectval(s);
243 + }
244 +
245 +
246   copyfile(in, out)                       /* copy a file */
247   register FILE  *in, *out;
248   {
# Line 312 | Line 331 | FILE  *in;
331  
332   scan2init()                     /* prepare scanline arrays */
333   {
334 <        double  e;
334 >        double  d;
335          register int  i;
336  
337          if (rad <= 0.0) {
# Line 341 | Line 360 | scan2init()                    /* prepare scanline arrays */
360                  fprintf(stderr, "%s: out of memory\n", progname);
361                  quit(1);
362          }
363 <        e = bright(exposure);
364 <        if (e < 1-1e-7 || e > 1+1e-7)           /* record exposure */
365 <                fputexpos(e, stdout);
363 >                                        /* record pixel aspect and exposure */
364 >        d = x_c / y_r;
365 >        if (d < .99 || d > 1.01)
366 >                fputaspect(d, stdout);
367 >        d = bright(exposure);
368 >        if (d < .995 || d > 1.005)
369 >                fputexpos(d, stdout);
370          printf("\n");
371          fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */
372   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines