From eb69eb7d172fbc5c032e2662215a4a1dffb7fff5 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Tue, 15 Jun 2021 17:56:18 +0200 Subject: [PATCH] Add tests for tiff encoder discontiguous buffers --- .../Formats/Tiff/TiffEncoderTests.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs index 0bb9b95b9..09505692f 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffEncoderTests.cs @@ -437,6 +437,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff //// CcittGroup3Fax compressed data length can be larger than the original length. Assert.Throws(() => TestStripLength(provider, photometricInterpretation, compression)); + [Theory] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.Rgb)] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.PaletteColor)] + [WithTestPatternImages(287, 321, PixelTypes.Rgba32, TiffPhotometricInterpretation.BlackIsZero)] + public void TiffEncode_WorksWithDiscontiguousBuffers(TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation) + where TPixel : unmanaged, IPixel + { + provider.LimitAllocatorBufferCapacity().InPixelsSqrt(200); + using Image image = provider.GetImage(); + + var encoder = new TiffEncoder { PhotometricInterpretation = photometricInterpretation }; + image.DebugSave(provider, encoder); + } + private static void TestStripLength( TestImageProvider provider, TiffPhotometricInterpretation photometricInterpretation,