diff --git a/doc/man/man1/rcrop.1 b/doc/man/man1/rcrop.1 index b89e26f7..87538559 100644 --- a/doc/man/man1/rcrop.1 +++ b/doc/man/man1/rcrop.1 @@ -1,4 +1,4 @@ -.\" RCSid "$Id: rcrop.1,v 1.8 2023/12/12 16:31:45 greg Exp $" +.\" RCSid "$Id: rcrop.1,v 1.9 2024/05/17 20:50:57 greg Exp $" .TH RCROP 1 3/14/2022 RADIANCE .SH NAME rcrop - crop RADIANCE matrix or picture @@ -35,6 +35,8 @@ If a 0 value is specified for the number of rows to copy, then all rows will be copied, starting from row0. Similarly, a 0 value for the number of columns to copy implies all columns >= col0 will be copied. +A negative count for the number of rows or columns cuts the +corresponding amount off the end(s). .PP Using .I rcrop diff --git a/doc/notes/ReleaseNotes b/doc/notes/ReleaseNotes index 1caf3dab..cc7c08fc 100644 --- a/doc/notes/ReleaseNotes +++ b/doc/notes/ReleaseNotes @@ -2693,3 +2693,5 @@ scenes with sharp cut-offs. Added -i option to gendaymtx to match -i option of gendaylit. Thanks to Yongqing for initial implementation. + +Changed rcrop so negative #rows or #cols counts back from end. diff --git a/src/util/rcrop.c b/src/util/rcrop.c index b95a8a8f..5ba506c4 100644 --- a/src/util/rcrop.c +++ b/src/util/rcrop.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcrop.c,v 1.15 2024/05/16 18:59:19 greg Exp $"; +static const char RCSid[] = "$Id: rcrop.c,v 1.16 2024/05/17 20:50:57 greg Exp $"; #endif /* * rcrop.c - crop a Radiance picture or matrix data @@ -269,7 +269,7 @@ main(int argc, char *argv[]) cmin = atoi(argv[2]); nrows = atoi(argv[3]); ncols = atoi(argv[4]); - if ((rmin < 0) | (cmin < 0) | (nrows < 0) | (ncols < 0)) + if ((rmin < 0) | (cmin < 0)) goto usage; if (argc <= 5) SET_FILE_BINARY(fp); @@ -301,10 +301,10 @@ main(int argc, char *argv[]) fputs(": missing input dimensions\n", stderr); return(1); } - if (!nrows) - nrows = numscans(&res) - rmin; - if (!ncols) - ncols = scanlen(&res) - cmin; + if (nrows <= 0 ) + nrows += numscans(&res) - rmin; + if (ncols <= 0) + ncols += scanlen(&res) - cmin; if ((nrows <= 0) | (ncols <= 0) | (rmin+nrows > numscans(&res)) | (cmin+ncols > scanlen(&res))) {