--- ray/src/px/pfilt.c 1996/05/22 10:42:08 2.18 +++ ray/src/px/pfilt.c 2003/06/30 14:59:12 2.25 @@ -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.25 2003/06/30 14:59:12 schorsch Exp $"; #endif - /* * pfilt.c - program to post-process picture file. * @@ -11,23 +8,22 @@ static char SCCSid[] = "$SunId$ LBL"; * 6/23/93 Added additional buffers for value spreading */ -#include "standard.h" +#include "copyright.h" #include +#include +#include "standard.h" +#include "platform.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 +88,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,18 +96,19 @@ 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); +#ifdef SIGHUP if (signal(SIGHUP, quit) == SIG_IGN) signal(SIGHUP, SIG_IGN); +#endif signal(SIGTERM, quit); +#ifdef SIGPIPE signal(SIGPIPE, quit); +#endif #ifdef SIGXCPU signal(SIGXCPU, quit); signal(SIGXFSZ, quit); @@ -205,7 +201,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 +328,7 @@ COLOR clr; double (*ourbright)() = rgb_bright; +int headline(s) /* process line from header */ char *s; { @@ -352,6 +349,7 @@ char *s; wrongformat = !globmatch(PICFMT, fmt); } else if (isview(s) && sscanview(&ourview, s) > 0) gotview++; + return(0); } @@ -399,7 +397,7 @@ FILE *in; } pass1scan(scan, i); } - free((char *)scan); + free((void *)scan); } @@ -414,7 +412,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 +429,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,13 +538,13 @@ 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 */ - bzero((char *)scoutbar[nextrow%obarsize], ncols*sizeof(COLOR)); + memset((char *)scoutbar[nextrow%obarsize], '\0', ncols*sizeof(COLOR)); nextrow++; } /* point to top scanline for output */ @@ -571,6 +569,7 @@ scan2flush() /* flush output buffer */ } +void quit(code) /* remove temporary file and exit */ int code; {