--- ray/src/px/pcomb.c 1996/09/05 10:38:53 2.19 +++ ray/src/px/pcomb.c 2004/03/15 21:16:54 2.31 @@ -1,27 +1,21 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: pcomb.c,v 2.31 2004/03/15 21:16:54 greg Exp $"; #endif - /* * Combine picture files according to calcomp functions. * * 1/4/89 */ -#include "standard.h" - +#include "platform.h" +#include "rtprocess.h" +#include "rterror.h" #include "color.h" - -#include "resolu.h" - #include "calcomp.h" - #include "view.h" #define MAXINP 32 /* maximum number of input files */ -#define WINSIZ 17 /* scanline window size */ +#define WINSIZ 64 /* scanline window size */ #define MIDSCN ((WINSIZ-1)/2+1) struct { @@ -39,6 +33,7 @@ int nfiles; /* number of input files */ char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ +char StandardInput[] = ""; char Command[] = ""; char vcolin[3][4] = {"ri", "gi", "bi"}; char vcolout[3][4] = {"ro", "go", "bo"}; @@ -76,10 +71,10 @@ char *progname; /* global argv[0] */ int wrongformat = 0; int gotview; -FILE *popen(); extern char *emalloc(); +static gethfunc tabputs; main(argc, argv) int argc; @@ -88,12 +83,9 @@ char *argv[]; int original; double f; int a, i; -#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); progname = argv[0]; /* scan options */ for (a = 1; a < argc; a++) { @@ -114,11 +106,12 @@ char *argv[]; break; } newheader("RADIANCE", stdout); /* start header */ + fputnow(stdout); /* process files */ for (nfiles = 0; nfiles < MAXINP; nfiles++) { setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); - copystruct(&input[nfiles].vw, &stdview); + input[nfiles].vw = stdview; input[nfiles].pa = 1.0; } nfiles = 0; @@ -132,7 +125,7 @@ char *argv[]; if (argv[a][0] == '-') switch (argv[a][1]) { case '\0': - input[nfiles].name = ""; + input[nfiles].name = StandardInput; input[nfiles].fp = stdin; break; case 'o': @@ -171,6 +164,7 @@ char *argv[]; colval(input[nfiles].expos,GRN); colval(input[nfiles].coef,BLU) /= colval(input[nfiles].expos,BLU); + setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); } nfiles++; original = 0; @@ -227,22 +221,25 @@ usage: } -tputs(s) /* put out string preceded by a tab */ -char *s; +static int +tabputs( /* put out string preceded by a tab */ + char *s, + void *p +) { char fmt[32]; double d; COLOR ctmp; if (isheadid(s)) /* header id */ - return; /* don't echo */ + return(0); /* don't echo */ if (formatval(fmt, s)) { /* check format */ if (globmatch(ourfmt, fmt)) { wrongformat = 0; strcpy(ourfmt, fmt); } else - wrongformat = 1; - return; /* don't echo */ + wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; + return(0); /* don't echo */ } if (isexpos(s)) { /* exposure */ d = exposval(s); @@ -256,7 +253,7 @@ char *s; gotview++; /* echo line */ putchar('\t'); - fputs(s, stdout); + return(fputs(s, stdout)); } @@ -267,12 +264,16 @@ checkfile() /* ready a file */ gotview = 0; fputs(input[nfiles].name, stdout); fputs(":\n", stdout); - getheader(input[nfiles].fp, tputs, NULL); - if (wrongformat) { + getheader(input[nfiles].fp, tabputs, NULL); + if (wrongformat < 0) { eputs(input[nfiles].name); - eputs(": not in Radiance picture format\n"); + eputs(": not a Radiance picture\n"); quit(1); } + if (wrongformat > 0) { + wputs(input[nfiles].name); + wputs(": warning -- incompatible picture format\n"); + } if (!gotview || setview(&input[nfiles].vw) != NULL) input[nfiles].vw.type = 0; if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { @@ -316,7 +317,8 @@ double (*ourbright)() = rgb_bright; init() /* perform final setup */ { - double l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize(); + double l_colin(char *), l_expos(char *), l_pixaspect(char *), + l_ray(char *), l_psize(char *); register int i; /* define constants */ varset("PI", ':', PI); @@ -397,7 +399,7 @@ combine() /* combine pictures */ quit(1); } } - efree(scanout); + efree((char *)scanout); } @@ -450,7 +452,7 @@ register char *nam; double -l_pixaspect() /* return pixel aspect ratio */ +l_pixaspect(char *nm) /* return pixel aspect ratio */ { register int fn; @@ -522,7 +524,7 @@ register char *nam; static unsigned long ltick[MAXINP]; static FVECT lorg[MAXINP], ldir[MAXINP]; static double ldist[MAXINP]; - FLOAT loc[2]; + RREAL loc[2]; int fn; register int i; @@ -531,9 +533,10 @@ register char *nam; errno = EDOM; return(0.0); } - if (ltick[fn] < eclock) { /* need to compute? */ + if (ltick[fn] != eclock) { /* need to compute? */ lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; + ldist[fn] = -1.0; if (input[fn].vw.type == 0) errno = EDOM; else { @@ -554,12 +557,12 @@ register char *nam; double -l_psize() /* compute pixel size in steradians */ +l_psize(char *nm) /* compute pixel size in steradians */ { static unsigned long ltick[MAXINP]; static double psize[MAXINP]; FVECT dir0, org, dirx, diry; - FLOAT locx[2], locy[2]; + RREAL locx[2], locy[2]; double d; int fn; register int i; @@ -570,7 +573,7 @@ l_psize() /* compute pixel size in steradians */ return(0.0); } fn = d - .5; - if (ltick[fn] < eclock) { /* need to compute? */ + if (ltick[fn] != eclock) { /* need to compute? */ psize[fn] = 0.0; if (input[fn].vw.type == 0) errno = EDOM; @@ -590,7 +593,7 @@ l_psize() /* compute pixel size in steradians */ diry[i] -= dir0[i]; } fcross(dir0, dirx, diry); - psize[fn] = 0.5 * sqrt(DOT(dir0,dir0)); + psize[fn] = sqrt(DOT(dir0,dir0)); } } ltick[fn] = eclock; @@ -599,23 +602,23 @@ l_psize() /* compute pixel size in steradians */ } -wputs(msg) -char *msg; +extern void +wputs(char *msg) { if (!nowarn) eputs(msg); } -eputs(msg) -char *msg; +extern void +eputs(char *msg) { fputs(msg, stderr); } -quit(code) /* exit gracefully */ -int code; +extern void +quit(int code) /* exit gracefully */ { register int i; /* close input files */