--- ray/src/px/pfilt.c 1991/04/18 14:35:21 1.16 +++ ray/src/px/pfilt.c 1991/12/19 14:51:52 2.2 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -16,6 +16,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" + extern char *malloc(); extern float *matchlamp(); @@ -49,6 +51,7 @@ char *tfname = NULL; char *lampdat = "lamp.tab"; /* lamp data file */ +int order; /* scanline ordering of input */ int xres, yres; /* resolution of input */ double inpaspect = 1.0; /* pixel aspect ratio of input */ int correctaspect = 0; /* aspect ratio correction? */ @@ -70,7 +73,7 @@ int argc; char **argv; { extern char *mktemp(); - extern double atof(), pow(); + extern double pow(); extern long ftell(); extern int quit(), headline(); FILE *fin; @@ -79,7 +82,7 @@ char **argv; long fpos; double outaspect = 0.0; double d; - int i; + int i, j; if (signal(SIGINT, quit) == SIG_IGN) signal(SIGINT, SIG_IGN); @@ -196,9 +199,9 @@ char **argv; fprintf(stderr, "%s: unknown lamp type\n", lamptype); quit(1); } - colval(exposure,RED) /= lampcolor[0]; - colval(exposure,GRN) /= lampcolor[1]; - colval(exposure,BLU) /= lampcolor[2]; + for (i = 0; i < 3; i++) + if (lampcolor[i] > 1e-4) + colval(exposure,i) /= lampcolor[i]; freelamps(); } /* open input file */ @@ -238,10 +241,12 @@ char **argv; /* add new header info. */ printargs(i, argv, stdout); /* get picture size */ - if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) { + if ((order = fgetresolu(&xres, &yres, fin)) < 0) { fprintf(stderr, "%s: bad picture size\n", progname); quit(1); } + if (!(order & YMAJOR)) + inpaspect = 1.0/inpaspect; /* compute output resolution */ if (ncols <= 0) ncols = x_c*xres + .5; @@ -403,7 +408,7 @@ scan2init() /* prepare scanline arrays */ initmask(); /* initialize filter table */ } - barsize = 2 * yrad; + barsize = 2*yrad + 1; scanin = (COLOR **)malloc(barsize*sizeof(COLOR *)); for (i = 0; i < barsize; i++) { scanin[i] = (COLOR *)malloc(xres*sizeof(COLOR)); @@ -419,7 +424,7 @@ scan2init() /* prepare scanline arrays */ } /* record pixel aspect ratio */ if (!correctaspect) { - d = x_c / y_r; + d = order & YMAJOR ? x_c/y_r : y_r/x_c ; if (!FEQ(d,1.0)) fputaspect(d, stdout); } @@ -435,7 +440,7 @@ scan2init() /* prepare scanline arrays */ fputcolcor(ctmp, stdout); printf("\n"); /* write out resolution */ - fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); + fputresolu(order, ncols, nrows, stdout); }