--- ray/src/util/rcrop.c 2022/03/15 02:28:05 1.4 +++ ray/src/util/rcrop.c 2022/03/15 20:54:49 1.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcrop.c,v 1.4 2022/03/15 02:28:05 greg Exp $"; +static const char RCSid[] = "$Id: rcrop.c,v 1.8 2022/03/15 20:54:49 greg Exp $"; #endif /* * rcrop.c - crop a Radiance picture or matrix data @@ -18,7 +18,7 @@ char *progname; /* global argv[0] */ VIEW vw = STDVIEW; int gotvw = 0; -char fmt[MAXFMTLEN] = "Unknown"; +char fmt[MAXFMTLEN] = "ascii"; /* assumed when unspecified */ int ncomp = 0; RESOLU res; int rmin, cmin, nrows, ncols; @@ -234,6 +234,10 @@ main(int argc, char *argv[]) fputs(": cannot open for writing\n", stderr); return(1); } +#ifdef getc_unlocked /* avoid stupid semaphores */ + flockfile(fp); + flockfile(stdout); +#endif /* process information header */ if (getheader(fp, headline, NULL) < 0) { fputs(progname, stderr); @@ -316,6 +320,12 @@ main(int argc, char *argv[]) asiz = sizeof(float); } else if (!strcmp(fmt, "double")) { asiz = sizeof(double); + } else if (!strcmp(fmt, "32-bit_encoded_normal")) { + asiz = 4; + ncomp = 1; + } else if (!strcmp(fmt, "16-bit_encoded_depth")) { + asiz = 2; + ncomp = 1; } else if (globmatch(PICFMT, fmt)) { asiz = -1; if (!ncomp) ncomp = 3; @@ -335,6 +345,11 @@ main(int argc, char *argv[]) if (!(asiz < 0 ? colr_copyf(fp) : !asiz ? ascii_copyf(fp) : binary_copyf(fp, asiz))) return(1); + /* need to consume the rest? */ + if (fp == stdin && rmin+nrows < numscans(&res) && + fseek(fp, 0L, SEEK_END) < 0) + while (getc(fp) != EOF) + ; return(0); usage: fputs("Usage: ", stderr);