--- ray/src/util/dctimestep.c 2019/02/23 18:25:12 2.39 +++ ray/src/util/dctimestep.c 2019/10/23 17:16:26 2.44 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: dctimestep.c,v 2.39 2019/02/23 18:25:12 greg Exp $"; +static const char RCSid[] = "$Id: dctimestep.c,v 2.44 2019/10/23 17:16:26 greg Exp $"; #endif /* * Compute time-step result using Daylight Coefficient method. @@ -48,7 +48,7 @@ sum_images(const char *fspec, const CMATRIX *cv, FILE error(SYSTEM, errmsg); } dt = DTfromHeader; - if ((err = cm_getheader(&dt, NULL, NULL, fp)) != NULL) + if ((err = cm_getheader(&dt, NULL, NULL, NULL, fp)) != NULL) error(USER, err); if ((dt != DTrgbe) & (dt != DTxyze) || !fscnresolu(&xr, &yr, fp)) { @@ -187,6 +187,9 @@ main(int argc, char *argv[]) case 'a': outfmt = DTascii; break; + case 'c': + outfmt = DTrgbe; + break; default: goto userr; } @@ -237,6 +240,10 @@ main(int argc, char *argv[]) ofspec = NULL; /* only need to open once */ } if (hasNumberFormat(argv[a])) { /* generating image(s) */ + if (outfmt != DTrgbe) { + error(WARNING, "changing output type to -oc"); + outfmt = DTrgbe; + } if (ofspec == NULL) { SET_FILE_BINARY(ofp); newheader("RADIANCE", ofp); @@ -247,7 +254,7 @@ main(int argc, char *argv[]) for (i = 0; i < nsteps; i++) { CMATRIX *cvec = cm_column(cmtx, i); if (ofspec != NULL) { - sprintf(fnbuf, ofspec, i+1); + sprintf(fnbuf, ofspec, i); if ((ofp = fopen(fnbuf, "wb")) == NULL) { fprintf(stderr, "%s: cannot open '%s' for output\n", @@ -258,7 +265,7 @@ main(int argc, char *argv[]) printargs(argc, argv, ofp); fputnow(ofp); } - fprintf(ofp, "FRAME=%d\n", i+1); + fprintf(ofp, "FRAME=%d\n", i); if (!sum_images(argv[a], cvec, ofp)) return(1); if (ofspec != NULL) { @@ -282,7 +289,7 @@ main(int argc, char *argv[]) const char *wtype = (outfmt==DTascii) ? "w" : "wb"; for (i = 0; i < nsteps; i++) { CMATRIX *rvec = cm_column(rmtx, i); - sprintf(fnbuf, ofspec, i+1); + sprintf(fnbuf, ofspec, i); if ((ofp = fopen(fnbuf, wtype)) == NULL) { fprintf(stderr, "%s: cannot open '%s' for output\n", @@ -296,9 +303,11 @@ main(int argc, char *argv[]) newheader("RADIANCE", ofp); printargs(argc, argv, ofp); fputnow(ofp); - fprintf(ofp, "FRAME=%d\n", i+1); + fprintf(ofp, "FRAME=%d\n", i); fprintf(ofp, "NROWS=%d\n", rvec->nrows); fputs("NCOLS=1\nNCOMP=3\n", ofp); + if ((outfmt == 'f') | (outfmt == 'd')) + fputendian(ofp); fputformat((char *)cm_fmt_id[outfmt], ofp); fputc('\n', ofp); } @@ -325,6 +334,8 @@ main(int argc, char *argv[]) fprintf(ofp, "NROWS=%d\n", rmtx->nrows); fprintf(ofp, "NCOLS=%d\n", rmtx->ncols); fputs("NCOMP=3\n", ofp); + if ((outfmt == 'f') | (outfmt == 'd')) + fputendian(ofp); fputformat((char *)cm_fmt_id[outfmt], ofp); fputc('\n', ofp); } @@ -339,9 +350,9 @@ main(int argc, char *argv[]) cm_free(cmtx); return(0); userr: - fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n", + fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d|c}] DCspec [skyf]\n", progname); - fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf Dmat.dat [skyf]\n", + fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d|c}] Vspec Tbsdf Dmat.dat [skyf]\n", progname); return(1); }