@@ -22,6 +22,12 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
22
22
23
23
private readonly TiffColorType colorType ;
24
24
25
+ private readonly bool isTiled ;
26
+
27
+ private readonly int tileWidth ;
28
+
29
+ private readonly int tileHeight ;
30
+
25
31
/// <summary>
26
32
/// Initializes a new instance of the <see cref="DeflateTiffCompression" /> class.
27
33
/// </summary>
@@ -31,11 +37,17 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
31
37
/// <param name="colorType">The color type of the pixel data.</param>
32
38
/// <param name="predictor">The tiff predictor used.</param>
33
39
/// <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 )
35
44
: base ( memoryAllocator , width , bitsPerPixel , predictor )
36
45
{
37
46
this . colorType = colorType ;
38
47
this . isBigEndian = isBigEndian ;
48
+ this . isTiled = isTiled ;
49
+ this . tileWidth = tileWidth ;
50
+ this . tileHeight = tileHeight ;
39
51
}
40
52
41
53
/// <inheritdoc/>
@@ -70,7 +82,15 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int
70
82
71
83
if ( this . Predictor == TiffPredictor . Horizontal )
72
84
{
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
+ }
74
94
}
75
95
}
76
96
0 commit comments