--- ray/src/px/pcomb.c 2005/01/24 19:29:39 2.35 +++ ray/src/px/pcomb.c 2007/11/05 23:40:26 2.41 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pcomb.c,v 2.35 2005/01/24 19:29:39 greg Exp $"; +static const char RCSid[] = "$Id: pcomb.c,v 2.41 2007/11/05 23:40:26 greg Exp $"; #endif /* * Combine picture files according to calcomp functions. @@ -14,7 +14,7 @@ static const char RCSid[] = "$Id: pcomb.c,v 2.35 2005/ #include "calcomp.h" #include "view.h" -#define MAXINP 32 /* maximum number of input files */ +#define MAXINP 512 /* maximum number of input files */ #define WINSIZ 64 /* scanline window size */ #define MIDSCN ((WINSIZ-1)/2+1) @@ -68,11 +68,12 @@ int xpos, ypos; /* output position */ char *progname; /* global argv[0] */ +int echoheader = 1; int wrongformat = 0; int gotview; -static gethfunc tabputs; +static gethfunc headline; static void checkfile(void); static double rgb_bright(COLOR clr); static double xyz_bright(COLOR clr); @@ -110,6 +111,9 @@ main( case 'w': nowarn = !nowarn; continue; + case 'h': + echoheader = !echoheader; + continue; case 'f': case 'e': a++; @@ -194,6 +198,8 @@ main( continue; case 'w': continue; + case 'h': + continue; case 'f': fcompile(argv[++a]); continue; @@ -228,14 +234,14 @@ usage: eputs("Usage: "); eputs(argv[0]); eputs( -" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); +" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); quit(1); return 1; /* pro forma return */ } static int -tabputs( /* put out string preceded by a tab */ +headline( /* check header line & echo if requested */ char *s, void *p ) @@ -264,9 +270,12 @@ tabputs( /* put out string preceded by a tab */ input[nfiles].pa *= aspectval(s); else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) gotview++; - /* echo line */ - putchar('\t'); - return(fputs(s, stdout)); + + if (echoheader) { /* echo line */ + putchar('\t'); + return(fputs(s, stdout)); + } + return(0); } @@ -276,9 +285,11 @@ checkfile(void) /* ready a file */ register int i; /* process header */ gotview = 0; - fputs(input[nfiles].name, stdout); - fputs(":\n", stdout); - getheader(input[nfiles].fp, tabputs, NULL); + if (echoheader) { + fputs(input[nfiles].name, stdout); + fputs(":\n", stdout); + } + getheader(input[nfiles].fp, headline, NULL); if (wrongformat < 0) { eputs(input[nfiles].name); eputs(": not a Radiance picture\n"); @@ -387,7 +398,7 @@ combine(void) /* combine pictures */ advance(); varset(vypos, '=', (double)ypos); for (xpos = 0; xpos < xres; xpos++) { - xscan = (long)xpos*xmax/xres; + xscan = (xpos+.5)*xmax/xres - .4999; varset(vxpos, '=', (double)xpos); eclock++; if (brtdef != NULL) { @@ -426,7 +437,7 @@ advance(void) /* read in data for next scanline */ register COLOR *st; register int i, j; - for (ytarget = (long)ypos*ymax/yres; yscan > ytarget; yscan--) + for (ytarget = (ypos+.5)*ymax/yres - .4999; yscan > ytarget; yscan--) for (i = 0; i < nfiles; i++) { st = input[i].scan[WINSIZ-1]; for (j = WINSIZ-1; j > 0; j--) /* rotate window */ @@ -439,11 +450,8 @@ advance(void) /* read in data for next scanline */ eputs(": read error\n"); quit(1); } - if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || - fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || - fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) - for (j = 0; j < xmax; j++) /* adjust color */ - multcolor(st[j], input[i].coef); + for (j = 0; j < xmax; j++) /* adjust color */ + multcolor(st[j], input[i].coef); } } @@ -601,7 +609,7 @@ l_psize(char *nm) /* compute pixel size in steradians if (input[fn].vw.type == 0) errno = EDOM; else if (input[fn].vw.type != VT_PAR && - funvalue(vray[6], 1, &d) > FTINY) { + funvalue(vray[6], 1, &d) >= -FTINY) { for (i = 0; i < 3; i++) dir0[i] = funvalue(vray[3+i], 1, &d); pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan);