--- ray/src/px/pfilt.c 1991/06/05 12:15:30 1.17 +++ ray/src/px/pfilt.c 1991/11/11 14:01:15 1.19 @@ -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? */ @@ -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; @@ -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); }