--- ray/src/px/pfilt.c 1993/06/25 17:07:03 2.10 +++ ray/src/px/pfilt.c 1995/10/16 12:04:36 2.15 @@ -53,6 +53,8 @@ double spread = 1e-4; /* spread for star points */ char *tfname = NULL; +char template[] = TEMPLATE; + char *lampdat = "lamp.tab"; /* lamp data file */ int order; /* scanline ordering of input */ @@ -100,7 +102,7 @@ char **argv; if (signal(SIGINT, quit) == SIG_IGN) signal(SIGINT, SIG_IGN); if (signal(SIGHUP, quit) == SIG_IGN) - signal(SIGINT, SIG_IGN); + signal(SIGHUP, SIG_IGN); signal(SIGTERM, quit); signal(SIGPIPE, quit); #ifdef SIGXCPU @@ -217,9 +219,9 @@ char **argv; fprintf(stderr, "%s: unknown lamp type\n", lamptype); quit(1); } - for (i = 0; i < 3; i++) - if (lampcolor[i] > 1e-4) - colval(exposure,i) /= lampcolor[i]; + for (j = 0; j < 3; j++) + if (lampcolor[j] > 1e-4) + colval(exposure,j) /= lampcolor[j]; freelamps(); } /* open input file */ @@ -227,7 +229,7 @@ char **argv; if (singlepass) fin = stdin; else { - tfname = mktemp(TEMPLATE); + tfname = mktemp(template); if ((fin = fopen(tfname, "w+")) == NULL) { fprintf(stderr, "%s: can't create ", progname); fprintf(stderr, "temp file \"%s\"\n", tfname); @@ -300,6 +302,25 @@ char **argv; } +double +rgb_bright(clr) +COLOR clr; +{ + return(bright(clr)); +} + + +double +xyz_bright(clr) +COLOR clr; +{ + return(clr[CIEY]); +} + + +double (*ourbright)() = rgb_bright; + + headline(s) /* process line from header */ char *s; { @@ -308,11 +329,16 @@ char *s; fputs(s, stdout); /* copy to output */ if (isaspect(s)) /* get aspect ratio */ inpaspect *= aspectval(s); - else if (isexpos(s)) + else if (isexpos(s)) /* get exposure */ hotlvl *= exposval(s); - else if (isformat(s)) { - formatval(fmt, s); - wrongformat = strcmp(fmt, COLRFMT); + else if (formatval(fmt, s)) { /* get format */ + wrongformat = 0; + if (!strcmp(COLRFMT, fmt)) + ourbright = rgb_bright; + else if (!strcmp(CIEFMT, fmt)) + ourbright = xyz_bright; + else + wrongformat = !globmatch(PICFMT, fmt); } } @@ -381,7 +407,7 @@ FILE *in; if (freadscan(scanin[yread%barsize], xres, in) < 0) { fprintf(stderr, - "%s: bad read (y=%d)\n", + "%s: truncated input (y=%d)\n", progname, yres-1-yread); quit(1); } @@ -473,7 +499,7 @@ scan2init() /* prepare scanline arrays */ fputaspect(d, stdout); } /* record exposure */ - d = bright(exposure); + d = (*ourbright)(exposure); if (!FEQ(d,1.0)) fputexpos(d, stdout); /* record color correction */ @@ -504,7 +530,7 @@ int r; ybot = (long)nextrow*yres/nrows; for (c = 0; c < ncols; c++) { dobox(ctmp, (int)((long)c*xres/ncols),ybot, c,nextrow); - greybar[nextrow%obarsize][c] = bright(ctmp); + greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); } /* and zero output scanline */ bzero((char *)scoutbar[nextrow%obarsize], ncols*sizeof(COLOR));