diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-03-07 03:56:38 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-03-07 03:56:38 +0000 |
commit | 7f8184372a7db4ad9ac7b30ce892b61e3d375dac (patch) | |
tree | 7c7acddb499d850c3cf22dbc2ddc71834a804e48 /editor/pamscale.c | |
parent | aff215cc29a295b7bdcc604ae1e71c5514113c29 (diff) | |
download | netpbm-mirror-7f8184372a7db4ad9ac7b30ce892b61e3d375dac.tar.gz netpbm-mirror-7f8184372a7db4ad9ac7b30ce892b61e3d375dac.tar.xz netpbm-mirror-7f8184372a7db4ad9ac7b30ce892b61e3d375dac.zip |
Release 10.93.01
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4038 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pamscale.c')
-rw-r--r-- | editor/pamscale.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/editor/pamscale.c b/editor/pamscale.c index d8436689..410cd94a 100644 --- a/editor/pamscale.c +++ b/editor/pamscale.c @@ -2108,33 +2108,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); } |