diff options
Diffstat (limited to 'lib/libpbm2.c')
-rw-r--r-- | lib/libpbm2.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/libpbm2.c b/lib/libpbm2.c index 0d824877..e12b1e33 100644 --- a/lib/libpbm2.c +++ b/lib/libpbm2.c @@ -10,6 +10,7 @@ ** implied warranty. */ +#include <assert.h> #include <limits.h> #include "pbm.h" @@ -257,7 +258,26 @@ pbm_readpbmrow_bitoffset(FILE * const ifP, window[last] = leftBits | rightBits; } -} +} + + + +void +pbm_cleanrowend_packed(unsigned char * const packedBits, + unsigned int const cols) { +/*---------------------------------------------------------------------------- + Set fractional "don't care" bits at end of row to zero. +----------------------------------------------------------------------------*/ + unsigned int const last = pbm_packed_bytes(cols) - 1; + unsigned int const bitsPerChar = 8; + + assert(cols > 0); + + if (cols % bitsPerChar > 0) { + packedBits[last] >>= bitsPerChar - cols % bitsPerChar; + packedBits[last] <<= bitsPerChar - cols % bitsPerChar; + } +} |