diff options
Diffstat (limited to 'editor/pamscale.c')
-rw-r--r-- | editor/pamscale.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/editor/pamscale.c b/editor/pamscale.c index d8436689..8a51b2be 100644 --- a/editor/pamscale.c +++ b/editor/pamscale.c @@ -636,7 +636,6 @@ parseCommandLine(int argc, --------------------------------------------------------------------------*/ optEntry * option_def; optStruct3 opt; - /* Instructions to pm_optParseOptions3 on how to parse our options. */ unsigned int option_def_index; unsigned int xyfit, xyfill; @@ -675,7 +674,7 @@ parseCommandLine(int argc, opt.short_allowed = false; /* We have no short (old-fashioned) options */ opt.allowNegNum = false; /* We have no parms that are negative numbers */ - pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); + pm_optParseOptions4(&argc, argv, opt, sizeof(opt), 0); /* Uses and sets argc, argv, and some of *cmdlineP and others. */ if (cmdlineP->nomix && filterSpec) @@ -2108,33 +2107,45 @@ scaleWithoutMixing(const struct pam * const inpamP, -----------------------------------------------------------------------------*/ tuple * tuplerow; /* An input row */ tuple * newtuplerow; - int row; - int rowInInput; + unsigned int row; + /* The number of the next row to be output */ + unsigned int rowInInput; + /* The number of the next row to be read from the input */ assert(outpamP->maxval == inpamP->maxval); assert(outpamP->depth == inpamP->depth); tuplerow = pnm_allocpamrow(inpamP); - rowInInput = -1; + rowInInput = 0; newtuplerow = pnm_allocpamrow(outpamP); for (row = 0; row < outpamP->height; ++row) { - int col; + unsigned int col; - int const inputRow = (int) (row / yscale); + unsigned int const inputRow = (int) (row / yscale); + /* The number of the input row that we will use for this output + row. + */ - for (; rowInInput < inputRow; ++rowInInput) + for (; rowInInput <= inputRow; ++rowInInput) pnm_readpamrow(inpamP, tuplerow); for (col = 0; col < outpamP->width; ++col) { - int const inputCol = (int) (col / xscale); + unsigned int const inputCol = (int) (col / xscale); pnm_assigntuple(inpamP, newtuplerow[col], tuplerow[inputCol]); } pnm_writepamrow(outpamP, newtuplerow); } + /* Read off and discard rest of rows, because whatever is supplying the + input stream may expect it to be consumed and because Caller will expect + the stream to be positioned to the next image. + */ + for (; rowInInput < inpamP->height; ++rowInInput) + pnm_readpamrow(inpamP, tuplerow); + pnm_freepamrow(tuplerow); pnm_freepamrow(newtuplerow); } @@ -2239,7 +2250,7 @@ pamscale(FILE * const ifP, int -main(int argc, const char **argv ) { +main(int argc, const char ** const argv) { struct CmdlineInfo cmdline; FILE * ifP; |