diff --git a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs index a3571388b2..022f04e1cf 100644 --- a/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs @@ -34,6 +34,11 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff /// private BufferedReadStream inputStream; + /// + /// RowsPerStrip default value, which is effectively infinity. + /// + private const int RowsPerStripInfinity = 2147483647; + /// /// Initializes a new instance of the class. /// @@ -281,6 +286,12 @@ namespace SixLabors.ImageSharp.Formats.Experimental.Tiff private void DecodeStripsChunky(ImageFrame frame, int rowsPerStrip, Number[] stripOffsets, Number[] stripByteCounts, int width) where TPixel : unmanaged, IPixel { + // If the rowsPerStrip has the default value, which is effectively infinity. That is, the entire image is one strip. + if (rowsPerStrip == RowsPerStripInfinity) + { + rowsPerStrip = frame.Height; + } + int uncompressedStripSize = this.CalculateStripBufferSize(frame.Width, rowsPerStrip); int bitsPerPixel = this.BitsPerPixel; diff --git a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs index f9ee8b1051..0fba4525bd 100644 --- a/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs @@ -137,6 +137,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff [WithFile(CcittFax3AllMakeupCodes, PixelTypes.Rgba32)] [WithFile(Calliphora_Fax3Compressed, PixelTypes.Rgba32)] [WithFile(Calliphora_Fax3Compressed_WithEolPadding, PixelTypes.Rgba32)] + [WithFile(Fax3Uncompressed, PixelTypes.Rgba32)] public void TiffDecoder_CanDecode_Fax3Compressed(TestImageProvider provider) where TPixel : unmanaged, IPixel => TestTiffDecoder(provider); diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 1c86289c58..300ab09b98 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -522,6 +522,7 @@ namespace SixLabors.ImageSharp.Tests public const string Calliphora_RgbPackbits = "Tiff/Calliphora_rgb_packbits.tiff"; public const string Calliphora_RgbUncompressed = "Tiff/Calliphora_rgb_uncompressed.tiff"; public const string Calliphora_Fax3Compressed = "Tiff/Calliphora_ccitt_fax3.tiff"; + public const string Fax3Uncompressed = "Tiff/ccitt_fax3_uncompressed.tiff"; public const string Calliphora_Fax3Compressed_WithEolPadding = "Tiff/Calliphora_ccitt_fax3_with_eol_padding.tiff"; public const string Calliphora_Fax4Compressed = "Tiff/Calliphora_ccitt_fax4.tiff"; public const string Calliphora_HuffmanCompressed = "Tiff/Calliphora_huffman_rle.tiff"; diff --git a/tests/Images/Input/Tiff/ccitt_fax3_uncompressed.tiff b/tests/Images/Input/Tiff/ccitt_fax3_uncompressed.tiff new file mode 100644 index 0000000000..d1bbbec427 --- /dev/null +++ b/tests/Images/Input/Tiff/ccitt_fax3_uncompressed.tiff @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f60615dea1b417ec125bf365b7c3a7c15ee2381947eb29dae2c34655fd0c2530 +size 821