1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
* Compute time-step glare using imageless DGP calculation method. |
6 |
|
* |
36 |
|
#include "resolu.h" |
37 |
|
#include "cmglare.h" |
38 |
|
|
36 |
– |
char *progname; /* global argv[0] */ |
37 |
– |
|
39 |
|
/* Sum together a set of images and write result to fout */ |
40 |
|
static int |
41 |
|
sum_images(const char *fspec, const CMATRIX *cv, FILE *fout) |
68 |
|
error(SYSTEM, errmsg); |
69 |
|
} |
70 |
|
dt = DTfromHeader; |
71 |
< |
if ((err = cm_getheader(&dt, NULL, NULL, NULL, fp)) != NULL) |
71 |
> |
if ((err = cm_getheader(&dt, NULL, NULL, NULL, NULL, fp)) != NULL) |
72 |
|
error(USER, err); |
73 |
|
if ((dt != DTrgbe) & (dt != DTxyze) || |
74 |
|
!fscnresolu(&xr, &yr, fp)) { |
84 |
|
pmat = cm_alloc(myYR, myXR); |
85 |
|
memset(pmat->cmem, 0, sizeof(COLOR)*myXR*myYR); |
86 |
|
/* finish header */ |
87 |
< |
fputformat((char *)cm_fmt_id[myDT], fout); |
87 |
> |
fputformat(cm_fmt_id[myDT], fout); |
88 |
|
fputc('\n', fout); |
89 |
|
fflush(fout); |
90 |
|
} else if ((dt != myDT) | (xr != myXR) | (yr != myYR)) { |
94 |
|
} |
95 |
|
/* flat file check */ |
96 |
|
if ((data_start = ftell(fp)) > 0 && fseek(fp, 0L, SEEK_END) == 0) { |
97 |
< |
flat_file = (ftell(fp) == data_start + sizeof(COLR)*xr*yr); |
97 |
> |
flat_file = (ftell(fp) >= data_start + sizeof(COLR)*xr*yr); |
98 |
|
if (fseek(fp, data_start, SEEK_SET) < 0) { |
99 |
|
sprintf(errmsg, "cannot seek on picture '%s'", fname); |
100 |
|
error(SYSTEM, errmsg); |
185 |
|
clock_t timer = clock(); |
186 |
|
#endif /* DC_GLARE */ |
187 |
|
|
188 |
< |
progname = argv[0]; |
188 |
> |
fixargv0(argv[0]); |
189 |
|
/* get options */ |
190 |
|
for (a = 1; a < argc && argv[a][0] == '-'; a++) |
191 |
|
switch (argv[a][1]) { |
301 |
|
if ((argc-a < 2) | (argc-a > 5)) |
302 |
|
goto userr; |
303 |
|
/* single bounce daylight coefficients file */ |
304 |
< |
direct_path = argv[++a]; |
304 |
> |
direct_path = argv[a++]; |
305 |
|
#else |
306 |
|
if ((argc-a < 1) | (argc-a > 4)) |
307 |
|
goto userr; |
476 |
|
fprintf(ofp, "FRAME=%d\n", i); |
477 |
|
fprintf(ofp, "NROWS=%d\n", rvec->nrows); |
478 |
|
fputs("NCOLS=1\nNCOMP=3\n", ofp); |
479 |
< |
if ((outfmt == 'f') | (outfmt == 'd')) |
479 |
> |
if ((outfmt == DTfloat) | (outfmt == DTdouble)) |
480 |
|
fputendian(ofp); |
481 |
< |
fputformat((char *)cm_fmt_id[outfmt], ofp); |
481 |
> |
fputformat(cm_fmt_id[outfmt], ofp); |
482 |
|
fputc('\n', ofp); |
483 |
|
} |
484 |
|
cm_write(rvec, outfmt, ofp); |
509 |
|
fprintf(ofp, "NCOLS=%d\n", rmtx->ncols); |
510 |
|
fputs("NCOMP=3\n", ofp); |
511 |
|
#endif /* DC_GLARE */ |
512 |
< |
if ((outfmt == 'f') | (outfmt == 'd')) |
512 |
> |
if ((outfmt == DTfloat) | (outfmt == DTdouble)) |
513 |
|
fputendian(ofp); |
514 |
< |
fputformat((char *)cm_fmt_id[outfmt], ofp); |
514 |
> |
fputformat(cm_fmt_id[outfmt], ofp); |
515 |
|
fputc('\n', ofp); |
516 |
|
} |
517 |
|
#ifdef DC_GLARE |