16 |
|
|
17 |
|
#include "color.h" |
18 |
|
|
19 |
+ |
#include "resolu.h" |
20 |
+ |
|
21 |
|
#include "calcomp.h" |
22 |
|
|
23 |
|
#define MAXINP 32 /* maximum number of input files */ |
124 |
|
goto usage; |
125 |
|
} |
126 |
|
else { |
127 |
< |
input[nfiles].name = argv[a]; |
128 |
< |
input[nfiles].fp = argv[a][0]=='!' ? |
129 |
< |
popen(argv[a]+1, "r") : |
130 |
< |
fopen(argv[a], "r"); |
127 |
> |
if (argv[a][0] == '!') { |
128 |
> |
input[nfiles].name = "<Command>"; |
129 |
> |
input[nfiles].fp = popen(argv[a]+1, "r"); |
130 |
> |
} else { |
131 |
> |
input[nfiles].name = argv[a]; |
132 |
> |
input[nfiles].fp = fopen(argv[a], "r"); |
133 |
> |
} |
134 |
|
if (input[nfiles].fp == NULL) { |
135 |
|
perror(argv[a]); |
136 |
|
quit(1); |
186 |
|
printargs(argc, argv, stdout); |
187 |
|
fputformat(COLRFMT, stdout); |
188 |
|
putchar('\n'); |
189 |
< |
fputresolu(YMAJOR|YDECR, xres, yres, stdout); |
189 |
> |
fprtresolu(xres, yres, stdout); |
190 |
|
/* combine pictures */ |
191 |
|
combine(); |
192 |
|
quit(0); |
237 |
|
eputs(": not in Radiance picture format\n"); |
238 |
|
quit(1); |
239 |
|
} |
240 |
< |
if (fgetresolu(&xinp, &yinp, input[nfiles].fp) != (YMAJOR|YDECR)) { |
240 |
> |
if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) { |
241 |
|
eputs(input[nfiles].name); |
242 |
|
eputs(": bad picture size\n"); |
243 |
|
quit(1); |
334 |
|
|
335 |
|
advance() /* read in data for next scanline */ |
336 |
|
{ |
337 |
+ |
extern double fabs(); |
338 |
|
int ytarget; |
339 |
|
register COLOR *st; |
340 |
|
register int i, j; |
347 |
|
input[i].scan[0] = st; |
348 |
|
if (yscan <= MIDSCN) /* hit bottom? */ |
349 |
|
continue; |
350 |
< |
if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ |
350 |
> |
if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ |
351 |
|
eputs(input[i].name); |
352 |
|
eputs(": read error\n"); |
353 |
|
quit(1); |
354 |
|
} |
355 |
< |
for (j = 0; j < xmax; j++) /* adjust color */ |
356 |
< |
multcolor(st[j], input[i].coef); |
355 |
> |
if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || |
356 |
> |
fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || |
357 |
> |
fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) |
358 |
> |
for (j = 0; j < xmax; j++) /* adjust color */ |
359 |
> |
multcolor(st[j], input[i].coef); |
360 |
|
} |
361 |
|
} |
362 |
|
|
453 |
|
} |
454 |
|
|
455 |
|
|
456 |
+ |
#ifdef NIX |
457 |
+ |
|
458 |
|
quit(code) |
459 |
< |
int code; |
459 |
> |
int code; |
460 |
|
{ |
461 |
|
exit(code); |
462 |
|
} |
463 |
+ |
|
464 |
+ |
#else |
465 |
+ |
|
466 |
+ |
quit(code) /* exit gracefully */ |
467 |
+ |
int code; |
468 |
+ |
{ |
469 |
+ |
int status; |
470 |
+ |
register int i; |
471 |
+ |
/* close input files */ |
472 |
+ |
for (i = 0; i < nfiles; i++) |
473 |
+ |
fclose(input[i].fp); |
474 |
+ |
/* reap children */ |
475 |
+ |
while (wait(&status) != -1) |
476 |
+ |
if (code == 0) |
477 |
+ |
code = status>>8 & 0xff; |
478 |
+ |
exit(code); |
479 |
+ |
} |
480 |
+ |
|
481 |
+ |
#endif |