From 343b4afc67cca8aa2ba115f1e6da64b35730f38e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 4 Aug 2022 17:19:28 +0200 Subject: [PATCH] Add another test case for #2172 --- .../Formats/Tga/TgaEncoderTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs index 50b4850caf..abe9e2a2d8 100644 --- a/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs @@ -135,6 +135,24 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga } } + // Run length encoded pixels should not exceed row boundaries. + // https://github.com/SixLabors/ImageSharp/pull/2172 + [Fact] + public void TgaEncoder_RunLengthDoesNotCrossRowBoundaries() + { + var options = new TgaEncoder() { Compression = TgaCompression.RunLength }; + + using (var input = new Image(30, 30)) + { + using (var memStream = new MemoryStream()) + { + input.Save(memStream, options); + byte[] imageBytes = memStream.ToArray(); + Assert.Equal(138, imageBytes.Length); + } + } + } + [Theory] [WithFile(Bit32BottomLeft, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel32)] [WithFile(Bit24BottomLeft, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel24)]