| 9 |
|
|
| 10 |
|
#include "platform.h" |
| 11 |
|
#include "standard.h" |
| 12 |
– |
#include "paths.h" |
| 12 |
|
#include "color.h" |
| 13 |
|
#include "calcomp.h" |
| 14 |
|
#include "view.h" |
| 69 |
|
|
| 70 |
|
int xpos, ypos; /* output position */ |
| 71 |
|
|
| 73 |
– |
char *progname; /* global argv[0] */ |
| 74 |
– |
|
| 72 |
|
int echoheader = 1; |
| 73 |
|
int wrongformat = 0; |
| 74 |
|
int gotview; |
| 101 |
|
SET_DEFAULT_BINARY(); |
| 102 |
|
SET_FILE_BINARY(stdin); |
| 103 |
|
SET_FILE_BINARY(stdout); |
| 104 |
< |
progname = argv[0]; |
| 104 |
> |
fixargv0(argv[0]); /* sets global progname */ |
| 105 |
|
esupport |= E_VARIABLE|E_FUNCTION|E_RCONST; |
| 106 |
|
esupport &= ~(E_OUTCHAN|E_INCHAN); |
| 107 |
|
/* scan options */ |
| 237 |
|
fprintview(commvp, stdout); |
| 238 |
|
fputc('\n', stdout); |
| 239 |
|
} |
| 240 |
< |
if (outfloat) { /* print format if known */ |
| 240 |
> |
if (outfloat) { /* print output format */ |
| 241 |
|
printf("NROWS=%d\nNCOLS=%d\n", yres, xres); |
| 242 |
|
fputncomp(outfloat, stdout); |
| 243 |
|
fputendian(stdout); |
| 244 |
|
fputformat("float", stdout); |
| 245 |
|
} else if (strcmp(ourfmt, PICFMT)) |
| 246 |
|
fputformat(ourfmt, stdout); |
| 247 |
+ |
else |
| 248 |
+ |
fputformat(COLRFMT, stdout); |
| 249 |
|
fputc('\n', stdout); /* end header */ |
| 250 |
|
if (!outfloat) |
| 251 |
|
fprtresolu(xres, yres, stdout); |
| 252 |
|
|
| 253 |
+ |
doptimize(1); /* optimize definitions */ |
| 254 |
|
combine(); /* combine pictures */ |
| 255 |
|
quit(0); |
| 256 |
|
usage: |
| 453 |
|
combine(void) /* combine pictures */ |
| 454 |
|
{ |
| 455 |
|
EPNODE *coldef[3], *brtdef; |
| 456 |
+ |
int set_x, set_y; |
| 457 |
|
COLOR *scanout; |
| 458 |
|
double d; |
| 459 |
|
int i, j; |
| 468 |
|
brtdef = eparse(vbrtout); |
| 469 |
|
else |
| 470 |
|
brtdef = NULL; |
| 471 |
+ |
/* what to set */ |
| 472 |
+ |
set_x = varlookup(vxpos) != NULL && !vardefined(vxpos); |
| 473 |
+ |
set_y = varlookup(vypos) != NULL && !vardefined(vypos); |
| 474 |
|
/* allocate scanline */ |
| 475 |
|
scanout = (COLOR *)emalloc(xres*sizeof(COLOR)); |
| 476 |
|
/* set input position */ |
| 478 |
|
/* combine files */ |
| 479 |
|
for (ypos = yres-1; ypos >= 0; ypos--) { |
| 480 |
|
advance(); |
| 481 |
< |
varset(vypos, '=', (double)ypos); |
| 481 |
> |
if (set_y) varset(vypos, '=', (double)ypos); |
| 482 |
|
for (xpos = 0; xpos < xres; xpos++) { |
| 483 |
|
xscan = (xpos+.5)*xmax/xres; |
| 484 |
< |
varset(vxpos, '=', (double)xpos); |
| 484 |
> |
if (set_x) varset(vxpos, '=', (double)xpos); |
| 485 |
|
eclock++; |
| 486 |
|
if (brtdef != NULL) { |
| 487 |
|
d = evalue(brtdef); |