Skip to content

Commit 343b4af

Browse files
committed
Add another test case for #2172
1 parent e717332 commit 343b4af

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/ImageSharp.Tests/Formats/Tga/TgaEncoderTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ public void TgaEncoder_DoesNotAlwaysUseRunLengthPackets<TPixel>(TestImageProvide
135135
}
136136
}
137137

138+
// Run length encoded pixels should not exceed row boundaries.
139+
// https://github.com/SixLabors/ImageSharp/pull/2172
140+
[Fact]
141+
public void TgaEncoder_RunLengthDoesNotCrossRowBoundaries()
142+
{
143+
var options = new TgaEncoder() { Compression = TgaCompression.RunLength };
144+
145+
using (var input = new Image<Rgba32>(30, 30))
146+
{
147+
using (var memStream = new MemoryStream())
148+
{
149+
input.Save(memStream, options);
150+
byte[] imageBytes = memStream.ToArray();
151+
Assert.Equal(138, imageBytes.Length);
152+
}
153+
}
154+
}
155+
138156
[Theory]
139157
[WithFile(Bit32BottomLeft, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel32)]
140158
[WithFile(Bit24BottomLeft, PixelTypes.Rgba32, TgaBitsPerPixel.Pixel24)]

0 commit comments

Comments
 (0)