--- ray/src/px/pcomb.c 1993/04/29 14:32:07 2.10 +++ ray/src/px/pcomb.c 1995/10/16 12:04:33 2.16 @@ -21,8 +21,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "view.h" #define MAXINP 32 /* maximum number of input files */ -#define WINSIZ 9 /* scanline window size */ -#define MIDSCN 4 /* current scan position */ +#define WINSIZ 17 /* scanline window size */ +#define MIDSCN ((WINSIZ-1)/2+1) struct { char *name; /* file or command name */ @@ -36,6 +36,8 @@ struct { int nfiles; /* number of input files */ +char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ + char Command[] = ""; char vcolin[3][4] = {"ri", "gi", "bi"}; char vcolout[3][4] = {"ro", "go", "bo"}; @@ -106,6 +108,7 @@ char *argv[]; } break; } + newheader("RADIANCE", stdout); /* start header */ /* process files */ for (nfiles = 0; nfiles < MAXINP; nfiles++) { setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); @@ -202,7 +205,8 @@ char *argv[]; } /* complete header */ printargs(argc, argv, stdout); - fputformat(COLRFMT, stdout); + if (strcmp(ourfmt, PICFMT)) + fputformat(ourfmt, stdout); /* print format if known */ putchar('\n'); fprtresolu(xres, yres, stdout); /* combine pictures */ @@ -224,10 +228,15 @@ char *s; double d; COLOR ctmp; - if (isformat(s)) { /* check format */ - formatval(fmt, s); - wrongformat = strcmp(fmt, COLRFMT); + if (isheadid(s)) /* header id */ return; /* 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 */ } if (isexpos(s)) { /* exposure */ d = exposval(s); @@ -278,6 +287,25 @@ checkfile() /* ready a file */ } +double +rgb_bright(clr) +COLOR clr; +{ + return(bright(clr)); +} + + +double +xyz_bright(clr) +COLOR clr; +{ + return(clr[CIEY]); +} + + +double (*ourbright)() = rgb_bright; + + init() /* perform final setup */ { double l_colin(), l_expos(), l_ray(); @@ -295,6 +323,9 @@ init() /* perform final setup */ funset(vbrtin, 1, '=', l_colin); for (i = 0; i < 6; i++) funset(vray[i], 1, '=', l_ray); + /* set brightness function */ + if (!strcmp(ourfmt, CIEFMT)) + ourbright = xyz_bright; } @@ -394,7 +425,7 @@ register char *nam; if (fn < 0 || fn >= nfiles) return(1.0); if (nam == vbrtexp) - return(bright(input[fn].expos)); + return((*ourbright)(input[fn].expos)); n = 3; while (n--) if (nam == vcolexp[n]) @@ -451,7 +482,7 @@ register char *nam; } } if (nam == vbrtin) - return(bright(input[fn].scan[MIDSCN+yoff][xscan+xoff])); + return((*ourbright)(input[fn].scan[MIDSCN+yoff][xscan+xoff])); n = 3; while (n--) if (nam == vcolin[n]) @@ -465,7 +496,7 @@ double l_ray(nam) /* return ray origin or direction */ register char *nam; { - static long ltick[MAXINP]; + static unsigned long ltick[MAXINP]; static FVECT lorg[MAXINP], ldir[MAXINP]; FLOAT loc[2]; double d; @@ -484,9 +515,9 @@ register char *nam; lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; if (input[fn].vw.type == 0) - errno = ERANGE; + errno = EDOM; else { - pix2loc(loc, &input[fn].rs, xpos, ypos); + pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan); if (viewray(lorg[fn], ldir[fn], &input[fn].vw, loc[0], loc[1]) < 0) errno = ERANGE;