]> granicus.if.org Git - imagemagick/commitdiff
Fix misaligned bits when writing .rfg
authorDavid Lechner <david@lechnology.com>
Sat, 23 Jul 2016 02:20:30 +0000 (21:20 -0500)
committerdirk <dirk@git.imagemagick.org>
Sat, 23 Jul 2016 11:21:52 +0000 (13:21 +0200)
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

index 92e0313c6f38b919dede0843696712768909c682..a09399013541459d04e6022c06421659c8b9837d 100644 (file)
@@ -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)