From: David Lechner Date: Sat, 23 Jul 2016 02:20:30 +0000 (-0500) Subject: Fix misaligned bits when writing .rfg X-Git-Tag: 7.0.2-6~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7cbd11037d7fca2552014b60aef66c40e74a899d;p=imagemagick Fix misaligned bits when writing .rfg When writing LEGO MINDSTORMS EV3 .rfg file, if the image is not a multiple of 8 pixels wide, the pixels in the last byte are not aligned correctly. The pixels need to be shifted the number of bits that are not used in the last byte. --- diff --git a/coders/rgf.c b/coders/rgf.c index 92e0313c6..a09399013 100644 --- a/coders/rgf.c +++ b/coders/rgf.c @@ -379,7 +379,10 @@ static MagickBooleanType WriteRGFImage(const ImageInfo *image_info,Image *image, p+=GetPixelChannels(image); } if (bit != 0) + { + byte >>= 8 - bit; (void) WriteBlobByte(image,(unsigned char) byte); + } status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse)