| 1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 12 |
|
|
| 13 |
|
#include <stdio.h> |
| 14 |
|
|
| 15 |
+ |
#include <math.h> |
| 16 |
+ |
|
| 17 |
+ |
#ifdef MSDOS |
| 18 |
+ |
#include <fcntl.h> |
| 19 |
+ |
#endif |
| 20 |
+ |
|
| 21 |
|
#include "color.h" |
| 22 |
|
|
| 23 |
|
#include "resolu.h" |
| 24 |
|
|
| 25 |
< |
#define MAXFILE 64 |
| 25 |
> |
#define MAXFILE 64 |
| 26 |
|
|
| 27 |
+ |
#define HASMIN 1 |
| 28 |
+ |
#define HASMAX 2 |
| 29 |
+ |
|
| 30 |
|
/* output picture size */ |
| 31 |
|
int xsiz = 0; |
| 32 |
|
int ysiz = 0; |
| 52 |
|
FILE *fp; /* stream pointer */ |
| 53 |
|
int xres, yres; /* picture size */ |
| 54 |
|
int xloc, yloc; /* anchor point */ |
| 55 |
< |
int hasmin, hasmax; /* has threshold values */ |
| 55 |
> |
int flags; /* HASMIN, HASMAX */ |
| 56 |
|
COLR thmin, thmax; /* thresholds */ |
| 57 |
|
} input[MAXFILE]; /* our input files */ |
| 58 |
|
|
| 62 |
|
|
| 63 |
|
FILE *popen(), *lblopen(); |
| 64 |
|
|
| 65 |
+ |
extern char *malloc(); |
| 66 |
|
|
| 67 |
+ |
|
| 68 |
|
tabputs(s) /* print line preceded by a tab */ |
| 69 |
|
char *s; |
| 70 |
|
{ |
| 87 |
|
int ncolumns = 0; |
| 88 |
|
int autolabel = 0; |
| 89 |
|
int curcol = 0, x0 = 0, curx = 0, cury = 0, spacing = 0; |
| 90 |
+ |
int xsgn, ysgn; |
| 91 |
|
char *thislabel; |
| 92 |
|
int an; |
| 93 |
< |
|
| 93 |
> |
#ifdef MSDOS |
| 94 |
> |
extern int _fmode; |
| 95 |
> |
_fmode = O_BINARY; |
| 96 |
> |
setmode(fileno(stdin), O_BINARY); |
| 97 |
> |
setmode(fileno(stdout), O_BINARY); |
| 98 |
> |
#endif |
| 99 |
|
progname = argv[0]; |
| 100 |
|
|
| 101 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
| 147 |
|
if (nfile >= MAXFILE) |
| 148 |
|
goto toomany; |
| 149 |
|
thislabel = NULL; |
| 150 |
< |
input[nfile].hasmin = input[nfile].hasmax = 0; |
| 151 |
< |
while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+')) |
| 150 |
> |
input[nfile].flags = 0; |
| 151 |
> |
xsgn = ysgn = '-'; |
| 152 |
> |
while (an < argc && (argv[an][0] == '-' || argv[an][0] == '+' |
| 153 |
> |
|| argv[an][0] == '=')) { |
| 154 |
|
switch (argv[an][1]) { |
| 155 |
|
case 't': |
| 156 |
|
checkthresh = 1; |
| 157 |
|
if (argv[an][0] == '-') { |
| 158 |
< |
input[nfile].hasmin = 1; |
| 158 |
> |
input[nfile].flags |= HASMIN; |
| 159 |
|
setcolr(input[nfile].thmin, |
| 160 |
|
atof(argv[an+1]), |
| 161 |
|
atof(argv[an+1]), |
| 162 |
|
atof(argv[an+1])); |
| 163 |
< |
} else { |
| 164 |
< |
input[nfile].hasmax = 1; |
| 163 |
> |
} else if (argv[an][0] == '+') { |
| 164 |
> |
input[nfile].flags |= HASMAX; |
| 165 |
|
setcolr(input[nfile].thmax, |
| 166 |
|
atof(argv[an+1]), |
| 167 |
|
atof(argv[an+1]), |
| 168 |
|
atof(argv[an+1])); |
| 169 |
< |
} |
| 170 |
< |
an += 2; |
| 169 |
> |
} else |
| 170 |
> |
goto userr; |
| 171 |
> |
an++; |
| 172 |
|
break; |
| 173 |
|
case 'l': |
| 174 |
|
if (strcmp(argv[an], "-l")) |
| 175 |
|
goto userr; |
| 176 |
< |
thislabel = argv[an+1]; |
| 157 |
< |
an += 2; |
| 176 |
> |
thislabel = argv[++an]; |
| 177 |
|
break; |
| 178 |
+ |
case '+': |
| 179 |
+ |
case '-': |
| 180 |
+ |
case '0': |
| 181 |
+ |
if (argv[an][0] != '=') |
| 182 |
+ |
goto userr; |
| 183 |
+ |
xsgn = argv[an][1]; |
| 184 |
+ |
ysgn = argv[an][2]; |
| 185 |
+ |
if (ysgn != '+' && ysgn != '-' && ysgn != '0') |
| 186 |
+ |
goto userr; |
| 187 |
+ |
break; |
| 188 |
|
case '\0': |
| 189 |
|
if (argv[an][0] == '-') |
| 190 |
|
goto getfile; |
| 192 |
|
default: |
| 193 |
|
goto userr; |
| 194 |
|
} |
| 195 |
+ |
an++; |
| 196 |
+ |
} |
| 197 |
|
getfile: |
| 198 |
|
if (argc-an < (ncolumns ? 1 : 3)) |
| 199 |
|
goto userr; |
| 243 |
|
curcol++; |
| 244 |
|
} else { |
| 245 |
|
input[nfile].xloc = atoi(argv[an++]); |
| 246 |
+ |
if (xsgn == '+') |
| 247 |
+ |
input[nfile].xloc -= input[nfile].xres; |
| 248 |
+ |
else if (xsgn == '0') |
| 249 |
+ |
input[nfile].xloc -= input[nfile].xres/2; |
| 250 |
|
input[nfile].yloc = atoi(argv[an++]); |
| 251 |
+ |
if (ysgn == '+') |
| 252 |
+ |
input[nfile].yloc -= input[nfile].yres; |
| 253 |
+ |
else if (ysgn == '0') |
| 254 |
+ |
input[nfile].yloc -= input[nfile].yres/2; |
| 255 |
|
} |
| 256 |
|
if (input[nfile].xloc < xmin) |
| 257 |
|
xmin = input[nfile].xloc; |
| 265 |
|
if (++nfile >= MAXFILE) |
| 266 |
|
goto toomany; |
| 267 |
|
input[nfile].name = Label; |
| 268 |
< |
input[nfile].hasmin = input[nfile].hasmax = 0; |
| 268 |
> |
input[nfile].flags = 0; |
| 269 |
|
input[nfile].xres = input[nfile-1].xres; |
| 270 |
|
input[nfile].yres = labelht; |
| 271 |
|
if ((input[nfile].fp = lblopen(thislabel, |
| 298 |
|
fprintf(stderr, |
| 299 |
|
"Usage: %s [-x xr][-y yr][-b r g b][-a n][-s p][-o x0 y0][-la][-lh h] ", |
| 300 |
|
progname); |
| 301 |
< |
fprintf(stderr, "[-t min1][+t max1][-l lab] pic1 x1 y1 ..\n"); |
| 301 |
> |
fprintf(stderr, "[-t min1][+t max1][-l lab][=SS] pic1 x1 y1 ..\n"); |
| 302 |
|
quit(1); |
| 303 |
|
toomany: |
| 304 |
|
fprintf(stderr, "%s: only %d files and labels allowed\n", |
| 347 |
|
if (x > xsiz) |
| 348 |
|
x = xsiz; |
| 349 |
|
for (x--; x >= 0 && x >= input[i].xloc; x--) { |
| 350 |
< |
if (input[i].hasmin && |
| 350 |
> |
if (input[i].flags & HASMIN && |
| 351 |
|
cmpcolr(scanin[x], input[i].thmin) <= 0) |
| 352 |
|
continue; |
| 353 |
< |
if (input[i].hasmax && |
| 353 |
> |
if (input[i].flags & HASMAX && |
| 354 |
|
cmpcolr(scanin[x], input[i].thmax) >= 0) |
| 355 |
|
continue; |
| 356 |
|
copycolr(scanout[x], scanin[x]); |