From b29cd27c1031a08fb78c50658fed9c8fabf23181 Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 7 Jun 2023 15:55:23 +0200 Subject: [PATCH] Fixed bug in Write1BitPixelData that wrote too many bits to the byte --- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index fd23a29e37..ce1660a912 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -668,7 +668,7 @@ internal sealed class BmpEncoderCore : IImageEncoderInternals if (quantizedPixelRow.Length % 8 != 0) { - int startIdx = quantizedPixelRow.Length - 7; + int startIdx = quantizedPixelRow.Length - (quantizedPixelRow.Length % 8); endIdx = quantizedPixelRow.Length; Write1BitPalette(stream, startIdx, endIdx, quantizedPixelRow); }