fix flush of left-over bits

we were not adjusting for pixel size, thanks MathemanFlo

see https://github.com/libvips/libvips/pull/1672#issuecomment-644807739
This commit is contained in:
John Cupitt 2020-06-18 14:54:09 +01:00
parent 1f8d007d19
commit b2feb4805f
1 changed files with 8 additions and 2 deletions

View File

@ -1310,8 +1310,14 @@ eightbit2nbit( Wtiff *wtiff, VipsPel *q, VipsPel *p, int n )
/* Any left-over bits? Need to be left-aligned.
*/
if( (x & pixel_mask) != 0 )
*q++ = (bits ^ mask) << (8 - (x & pixel_mask));
if( (x & pixel_mask) != 0 ) {
/* The number of bits we've collected in bits and must
* left-align and flush.
*/
int collected_bits = (x & pixel_mask) << (wtiff->bitdepth - 1);
*q++ = (bits ^ mask) << (8 - collected_bits);
}
}
/* Swap the sense of the first channel, if necessary.