--- ray/src/px/pfilt.c 1989/04/11 21:39:00 1.3 +++ ray/src/px/pfilt.c 1989/09/13 17:16:37 1.7 @@ -28,8 +28,8 @@ double rad = 0.0; /* output pixel radius for filteri int nrows = 0; /* number of rows for output */ int ncols = 0; /* number of columns for output */ -double xrat = 1.0; /* ratio of input x size to output */ -double yrat = 1.0; /* ratio of input y size to output */ +double x_c = 1.0; /* ratio of output x size to input */ +double y_r = 1.0; /* ratio of output y size to input */ int singlepass = 0; /* true means skip first pass */ @@ -47,8 +47,6 @@ char *tfname = NULL; int xres, yres; /* resolution of input */ -double x_c, y_r; /* conversion factors */ - int xrad; /* x window size */ int yrad; /* y window size */ @@ -90,16 +88,18 @@ char **argv; switch (argv[i][1]) { case 'x': i++; - if (argv[i][0] == '/') - xrat = atof(argv[i]+1); - else + if (argv[i][0] == '/') { + x_c = 1.0/atof(argv[i]+1); + ncols = 0; + } else ncols = atoi(argv[i]); break; case 'y': i++; - if (argv[i][0] == '/') - yrat = atof(argv[i]+1); - else + if (argv[i][0] == '/') { + y_r = 1.0/atof(argv[i]+1); + nrows = 0; + } else nrows = atoi(argv[i]); break; case 'e': @@ -128,6 +128,9 @@ char **argv; case '1': singlepass = 1; break; + case '2': + singlepass = 0; + break; case 'p': npts = atoi(argv[++i]) / 2; break; @@ -187,18 +190,18 @@ char **argv; /* add new header info. */ printargs(i, argv, stdout); /* get picture size */ - if (fscanf(fin, "-Y %d +X %d\n", &yres, &xres) != 2) { + if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) { fprintf(stderr, "%s: bad picture size\n", progname); quit(1); } if (ncols > 0) - xrat = (double)xres/ncols; + x_c = (double)ncols/xres; else - ncols = xres/xrat + .5; + ncols = x_c*xres + .5; if (nrows > 0) - yrat = (double)yres/nrows; + y_r = (double)nrows/yres; else - nrows = yres/yrat + .5; + nrows = y_r*yres + .5; if (singlepass) { /* skip exposure, etc. */ @@ -312,9 +315,6 @@ scan2init() /* prepare scanline arrays */ double e; register int i; - x_c = (double)ncols/xres; - y_r = (double)nrows/yres; - if (rad <= 0.0) { xrad = xres/ncols/2 + 1; yrad = yres/nrows/2 + 1; @@ -345,7 +345,7 @@ scan2init() /* prepare scanline arrays */ if (e < 1-1e-7 || e > 1+1e-7) /* record exposure */ printf("EXPOSURE=%e\n", e); printf("\n"); - printf("-Y %d +X %d\n", nrows, ncols); /* write picture size */ + fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */ }