@@ -22,6 +22,12 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
2222
2323 private readonly TiffColorType colorType ;
2424
25+ private readonly bool isTiled ;
26+
27+ private readonly int tileWidth ;
28+
29+ private readonly int tileHeight ;
30+
2531 /// <summary>
2632 /// Initializes a new instance of the <see cref="DeflateTiffCompression" /> class.
2733 /// </summary>
@@ -31,11 +37,17 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
3137 /// <param name="colorType">The color type of the pixel data.</param>
3238 /// <param name="predictor">The tiff predictor used.</param>
3339 /// <param name="isBigEndian">if set to <c>true</c> decodes the pixel data as big endian, otherwise as little endian.</param>
34- public DeflateTiffCompression ( MemoryAllocator memoryAllocator , int width , int bitsPerPixel , TiffColorType colorType , TiffPredictor predictor , bool isBigEndian )
40+ /// <param name="isTiled">Flag indicates, if the image is a tiled image.</param>
41+ /// <param name="tileWidth">Number of pixels in a tile row.</param>
42+ /// <param name="tileHeight">Number of rows in a tile.</param>
43+ public DeflateTiffCompression ( MemoryAllocator memoryAllocator , int width , int bitsPerPixel , TiffColorType colorType , TiffPredictor predictor , bool isBigEndian , bool isTiled , int tileWidth , int tileHeight )
3544 : base ( memoryAllocator , width , bitsPerPixel , predictor )
3645 {
3746 this . colorType = colorType ;
3847 this . isBigEndian = isBigEndian ;
48+ this . isTiled = isTiled ;
49+ this . tileWidth = tileWidth ;
50+ this . tileHeight = tileHeight ;
3951 }
4052
4153 /// <inheritdoc/>
@@ -70,7 +82,15 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int
7082
7183 if ( this . Predictor == TiffPredictor . Horizontal )
7284 {
73- HorizontalPredictor . Undo ( buffer , this . Width , this . colorType , this . isBigEndian ) ;
85+ if ( this . isTiled )
86+ {
87+ // When the image is tiled, undoing the horizontal predictor will be done for each tile row.
88+ HorizontalPredictor . UndoTile ( buffer , this . tileWidth , this . tileHeight , this . colorType , this . isBigEndian ) ;
89+ }
90+ else
91+ {
92+ HorizontalPredictor . Undo ( buffer , this . Width , this . colorType , this . isBigEndian ) ;
93+ }
7494 }
7595 }
7696
0 commit comments