1 |
– |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* pfilt.c - program to post-process picture file. |
6 |
|
* |
8 |
|
* 6/23/93 Added additional buffers for value spreading |
9 |
|
*/ |
10 |
|
|
14 |
– |
#include "standard.h" |
15 |
– |
|
11 |
|
#include <signal.h> |
12 |
|
|
13 |
+ |
#include "standard.h" |
14 |
|
#include "color.h" |
19 |
– |
|
15 |
|
#include "view.h" |
21 |
– |
|
22 |
– |
#include "resolu.h" |
23 |
– |
|
16 |
|
#include "paths.h" |
17 |
|
|
18 |
|
extern float *matchlamp(); |
19 |
|
|
20 |
|
#define FEQ(a,b) ((a) >= .98*(b) && (a) <= 1.02*(b)) |
21 |
|
|
22 |
< |
double CHECKRAD = 1.5; /* radius to check for filtering */ |
22 |
> |
double CHECKRAD = 2.0; /* radius to check for filtering */ |
23 |
|
|
24 |
|
#define THRESHRAD 5.0 /* maximum sample spread in output */ |
25 |
|
|
84 |
|
int argc; |
85 |
|
char **argv; |
86 |
|
{ |
87 |
< |
extern long ftell(); |
96 |
< |
extern int quit(), headline(); |
87 |
> |
extern int headline(); |
88 |
|
FILE *fin; |
89 |
|
float *lampcolor; |
90 |
|
char *lamptype = NULL; |
92 |
|
double outaspect = 0.0; |
93 |
|
double d; |
94 |
|
int i, j; |
95 |
< |
#ifdef MSDOS |
96 |
< |
extern int _fmode; |
97 |
< |
_fmode = O_BINARY; |
107 |
< |
setmode(fileno(stdin), O_BINARY); |
108 |
< |
setmode(fileno(stdout), O_BINARY); |
109 |
< |
#endif |
95 |
> |
SET_DEFAULT_BINARY(); |
96 |
> |
SET_FILE_BINARY(stdin); |
97 |
> |
SET_FILE_BINARY(stdout); |
98 |
|
if (signal(SIGINT, quit) == SIG_IGN) |
99 |
|
signal(SIGINT, SIG_IGN); |
100 |
|
if (signal(SIGHUP, quit) == SIG_IGN) |
193 |
|
case 'm': |
194 |
|
thresh = atof(argv[++i]); |
195 |
|
if (rad <= FTINY) |
196 |
< |
rad = 1.0; |
196 |
> |
rad = 0.6; |
197 |
|
break; |
198 |
|
case 'b': |
199 |
|
rad = thresh = 0.0; |
320 |
|
double (*ourbright)() = rgb_bright; |
321 |
|
|
322 |
|
|
323 |
+ |
int |
324 |
|
headline(s) /* process line from header */ |
325 |
|
char *s; |
326 |
|
{ |
341 |
|
wrongformat = !globmatch(PICFMT, fmt); |
342 |
|
} else if (isview(s) && sscanview(&ourview, s) > 0) |
343 |
|
gotview++; |
344 |
+ |
return(0); |
345 |
|
} |
346 |
|
|
347 |
|
|
389 |
|
} |
390 |
|
pass1scan(scan, i); |
391 |
|
} |
392 |
< |
free((char *)scan); |
392 |
> |
free((void *)scan); |
393 |
|
} |
394 |
|
|
395 |
|
|
404 |
|
scan2init(); |
405 |
|
yread = 0; |
406 |
|
for (r = 0; r < nrows; r++) { |
407 |
< |
ycent = (long)r*yres/nrows; |
407 |
> |
ycent = (r+.5)*yres/nrows; |
408 |
|
while (yread <= ycent+yrad) { |
409 |
|
if (yread < yres) { |
410 |
|
if (freadscan(scanin[yread%barsize], |
421 |
|
if (obarsize > 0) |
422 |
|
scan2sync(r); |
423 |
|
for (c = 0; c < ncols; c++) { |
424 |
< |
xcent = (long)c*xres/ncols; |
424 |
> |
xcent = (c+.5)*xres/ncols; |
425 |
|
if (thresh > FTINY) |
426 |
|
dothresh(xcent, ycent, c, r); |
427 |
|
else if (rad > FTINY) |
530 |
|
register int c; |
531 |
|
/* average input scanlines */ |
532 |
|
while (nextrow <= r+orad && nextrow < nrows) { |
533 |
< |
ybot = (long)nextrow*yres/nrows; |
533 |
> |
ybot = (nextrow+.5)*yres/nrows; |
534 |
|
for (c = 0; c < ncols; c++) { |
535 |
< |
dobox(ctmp, (int)((long)c*xres/ncols),ybot, c,nextrow); |
535 |
> |
dobox(ctmp, (int)((c+.5)*xres/ncols),ybot, c,nextrow); |
536 |
|
greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); |
537 |
|
} |
538 |
|
/* and zero output scanline */ |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
+ |
void |
565 |
|
quit(code) /* remove temporary file and exit */ |
566 |
|
int code; |
567 |
|
{ |