--- ray/src/px/pcomb.c 1992/03/27 10:04:12 2.2 +++ ray/src/px/pcomb.c 1992/09/21 12:13:48 2.7 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -12,6 +12,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#ifdef MSDOS +#include +#endif + #include #include "color.h" @@ -34,6 +38,7 @@ struct { int nfiles; /* number of input files */ +char Command[] = ""; char vcolin[3][4] = {"ri", "gi", "bi"}; char vcolout[3][4] = {"ro", "go", "bo"}; char vbrtin[] = "li"; @@ -63,7 +68,9 @@ int wrongformat = 0; FILE *popen(); +extern char *emalloc(); + main(argc, argv) int argc; char *argv[]; @@ -71,6 +78,12 @@ 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 /* scan options */ for (a = 1; a < argc; a++) { if (argv[a][0] == '-') @@ -125,7 +138,7 @@ char *argv[]; } else { if (argv[a][0] == '!') { - input[nfiles].name = ""; + input[nfiles].name = Command; input[nfiles].fp = popen(argv[a]+1, "r"); } else { input[nfiles].name = argv[a]; @@ -334,6 +347,7 @@ combine() /* combine pictures */ advance() /* read in data for next scanline */ { + extern double fabs(); int ytarget; register COLOR *st; register int i, j; @@ -346,13 +360,16 @@ advance() /* read in data for next scanline */ input[i].scan[0] = st; if (yscan <= MIDSCN) /* hit bottom? */ continue; - if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ + if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ eputs(input[i].name); eputs(": read error\n"); quit(1); } - for (j = 0; j < xmax; j++) /* adjust color */ - multcolor(st[j], input[i].coef); + 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); } } @@ -449,8 +466,15 @@ char *msg; } -quit(code) -int code; +quit(code) /* exit gracefully */ +int code; { + register int i; + /* close input files */ + for (i = 0; i < nfiles; i++) + if (input[i].name == Command) + pclose(input[i].fp); + else + fclose(input[i].fp); exit(code); }