--- ray/src/px/pfilt.c 1996/05/22 10:42:08 2.18 +++ ray/src/px/pfilt.c 2003/06/05 19:29:34 2.23 @@ -1,9 +1,6 @@ -/* Copyright (c) 1996 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: pfilt.c,v 2.23 2003/06/05 19:29:34 schorsch Exp $"; #endif - /* * pfilt.c - program to post-process picture file. * @@ -11,23 +8,18 @@ static char SCCSid[] = "$SunId$ LBL"; * 6/23/93 Added additional buffers for value spreading */ -#include "standard.h" - #include +#include "standard.h" #include "color.h" - #include "view.h" - -#include "resolu.h" - #include "paths.h" extern float *matchlamp(); #define FEQ(a,b) ((a) >= .98*(b) && (a) <= 1.02*(b)) -double CHECKRAD = 1.5; /* radius to check for filtering */ +double CHECKRAD = 2.0; /* radius to check for filtering */ #define THRESHRAD 5.0 /* maximum sample spread in output */ @@ -92,8 +84,7 @@ main(argc, argv) int argc; char **argv; { - extern long ftell(); - extern int quit(), headline(); + extern int headline(); FILE *fin; float *lampcolor; char *lamptype = NULL; @@ -101,12 +92,9 @@ char **argv; double outaspect = 0.0; double d; int i, j; -#ifdef MSDOS - extern int _fmode; - _fmode = O_BINARY; - setmode(fileno(stdin), O_BINARY); - setmode(fileno(stdout), O_BINARY); -#endif + SET_DEFAULT_BINARY(); + SET_FILE_BINARY(stdin); + SET_FILE_BINARY(stdout); if (signal(SIGINT, quit) == SIG_IGN) signal(SIGINT, SIG_IGN); if (signal(SIGHUP, quit) == SIG_IGN) @@ -205,7 +193,7 @@ char **argv; case 'm': thresh = atof(argv[++i]); if (rad <= FTINY) - rad = 1.0; + rad = 0.6; break; case 'b': rad = thresh = 0.0; @@ -332,6 +320,7 @@ COLOR clr; double (*ourbright)() = rgb_bright; +int headline(s) /* process line from header */ char *s; { @@ -352,6 +341,7 @@ char *s; wrongformat = !globmatch(PICFMT, fmt); } else if (isview(s) && sscanview(&ourview, s) > 0) gotview++; + return(0); } @@ -399,7 +389,7 @@ FILE *in; } pass1scan(scan, i); } - free((char *)scan); + free((void *)scan); } @@ -414,7 +404,7 @@ FILE *in; scan2init(); yread = 0; for (r = 0; r < nrows; r++) { - ycent = (long)r*yres/nrows; + ycent = (r+.5)*yres/nrows; while (yread <= ycent+yrad) { if (yread < yres) { if (freadscan(scanin[yread%barsize], @@ -431,7 +421,7 @@ FILE *in; if (obarsize > 0) scan2sync(r); for (c = 0; c < ncols; c++) { - xcent = (long)c*xres/ncols; + xcent = (c+.5)*xres/ncols; if (thresh > FTINY) dothresh(xcent, ycent, c, r); else if (rad > FTINY) @@ -540,9 +530,9 @@ int r; register int c; /* average input scanlines */ while (nextrow <= r+orad && nextrow < nrows) { - ybot = (long)nextrow*yres/nrows; + ybot = (nextrow+.5)*yres/nrows; for (c = 0; c < ncols; c++) { - dobox(ctmp, (int)((long)c*xres/ncols),ybot, c,nextrow); + dobox(ctmp, (int)((c+.5)*xres/ncols),ybot, c,nextrow); greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); } /* and zero output scanline */ @@ -571,6 +561,7 @@ scan2flush() /* flush output buffer */ } +void quit(code) /* remove temporary file and exit */ int code; {