From 7cbd11037d7fca2552014b60aef66c40e74a899d Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 22 Jul 2016 21:20:30 -0500 Subject: [PATCH] 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. --- coders/rgf.c | 3 +++ 1 file changed, 3 insertions(+) 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) -- 2.40.0