--- ray/src/px/pcompos.c 1992/09/08 10:36:22 2.14 +++ ray/src/px/pcompos.c 1994/02/27 10:17:04 2.18 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1993 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -12,12 +12,21 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + +#ifdef MSDOS +#include +#endif + #include "color.h" #include "resolu.h" -#define MAXFILE 64 +#define MAXFILE 64 +#define HASMIN 1 +#define HASMAX 2 + /* output picture size */ int xsiz = 0; int ysiz = 0; @@ -43,7 +52,7 @@ struct { FILE *fp; /* stream pointer */ int xres, yres; /* picture size */ int xloc, yloc; /* anchor point */ - int hasmin, hasmax; /* has threshold values */ + int flags; /* HASMIN, HASMAX */ COLR thmin, thmax; /* thresholds */ } input[MAXFILE]; /* our input files */ @@ -53,16 +62,19 @@ int wrongformat = 0; FILE *popen(), *lblopen(); +extern char *malloc(); + tabputs(s) /* print line preceded by a tab */ char *s; { char fmt[32]; - if (isformat(s)) { - formatval(fmt, s); + if (isheadid(s)) + return; + if (formatval(fmt, s)) wrongformat = strcmp(fmt, COLRFMT); - } else { + else { putc('\t', stdout); fputs(s, stdout); } @@ -76,9 +88,15 @@ char *argv[]; int ncolumns = 0; int autolabel = 0; int curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0; + int xsgn, ysgn; char *thislabel; int an; - +#ifdef MSDOS + extern int _fmode; + _fmode = O_BINARY; + setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdout), O_BINARY); +#endif progname = argv[0]; for (an = 1; an < argc && argv[an][0] == '-'; an++) @@ -126,36 +144,49 @@ char *argv[]; goto userr; } dofiles: + newheader("RADIANCE", stdout); for (nfile = 0; an < argc; nfile++) { if (nfile >= MAXFILE) goto toomany; thislabel = NULL; - input[nfile].hasmin = input[nfile].hasmax = 0; - while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) + input[nfile].flags = 0; + xsgn = ysgn = '-'; + while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+' + || argv[an][0] == '=')) { switch (argv[an][1]) { case 't': checkthresh = 1; if (argv[an][0] == '-') { - input[nfile].hasmin = 1; + input[nfile].flags |= HASMIN; setcolr(input[nfile].thmin, atof(argv[an+1]), atof(argv[an+1]), atof(argv[an+1])); - } else { - input[nfile].hasmax = 1; + } else if (argv[an][0] == '+') { + input[nfile].flags |= HASMAX; setcolr(input[nfile].thmax, atof(argv[an+1]), atof(argv[an+1]), atof(argv[an+1])); - } - an += 2; + } else + goto userr; + an++; break; case 'l': if (strcmp(argv[an], "-l")) goto userr; - thislabel = argv[an+1]; - an += 2; + thislabel = argv[++an]; break; + case '+': + case '-': + case '0': + if (argv[an][0] != '=') + goto userr; + xsgn = argv[an][1]; + ysgn = argv[an][2]; + if (ysgn != '+' && ysgn != '-' && ysgn != '0') + goto userr; + break; case '\0': if (argv[an][0] == '-') goto getfile; @@ -163,6 +194,8 @@ dofiles: default: goto userr; } + an++; + } getfile: if (argc-an < (ncolumns ? 1 : 3)) goto userr; @@ -212,7 +245,15 @@ getfile: curcol++; } else { input[nfile].xloc = atoi(argv[an++]); + if (xsgn == '+') + input[nfile].xloc -= input[nfile].xres; + else if (xsgn == '0') + input[nfile].xloc -= input[nfile].xres/2; input[nfile].yloc = atoi(argv[an++]); + if (ysgn == '+') + input[nfile].yloc -= input[nfile].yres; + else if (ysgn == '0') + input[nfile].yloc -= input[nfile].yres/2; } if (input[nfile].xloc < xmin) xmin = input[nfile].xloc; @@ -226,7 +267,7 @@ getfile: if (++nfile >= MAXFILE) goto toomany; input[nfile].name = Label; - input[nfile].hasmin = input[nfile].hasmax = 0; + input[nfile].flags = 0; input[nfile].xres = input[nfile-1].xres; input[nfile].yres = labelht; if ((input[nfile].fp = lblopen(thislabel, @@ -259,7 +300,7 @@ userr: fprintf(stderr, "Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", progname); - fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n"); + fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n"); quit(1); toomany: fprintf(stderr, "%s: only %d files and labels allowed\n", @@ -308,10 +349,10 @@ compos() /* composite pictures */ if (x > xsiz) x = xsiz; for (x--; x >= 0 && x >= input[i].xloc; x--) { - if (input[i].hasmin && + if (input[i].flags & HASMIN && cmpcolr(scanin[x], input[i].thmin) <= 0) continue; - if (input[i].hasmax && + if (input[i].flags & HASMAX && cmpcolr(scanin[x], input[i].thmax) >= 0) continue; copycolr(scanout[x], scanin[x]);