Skip to content

Commit 51e519e

Browse files
authored
Merge branch 'master' into bp/deduceColorSpaceFix
2 parents 68a706f + 74283c7 commit 51e519e

39 files changed

+730
-42
lines changed

src/ImageSharp/Formats/Tiff/Compression/Decompressors/DeflateTiffCompression.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using System.IO.Compression;
66

77
using SixLabors.ImageSharp.Compression.Zlib;
8-
using SixLabors.ImageSharp.Formats.Tiff.Compression;
98
using SixLabors.ImageSharp.Formats.Tiff.Constants;
9+
using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation;
1010
using SixLabors.ImageSharp.IO;
1111
using SixLabors.ImageSharp.Memory;
1212

@@ -20,16 +20,24 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
2020
/// </remarks>
2121
internal class DeflateTiffCompression : TiffBaseDecompressor
2222
{
23+
private readonly bool isBigEndian;
24+
25+
private readonly TiffColorType colorType;
26+
2327
/// <summary>
2428
/// Initializes a new instance of the <see cref="DeflateTiffCompression" /> class.
2529
/// </summary>
2630
/// <param name="memoryAllocator">The memoryAllocator to use for buffer allocations.</param>
2731
/// <param name="width">The image width.</param>
2832
/// <param name="bitsPerPixel">The bits used per pixel.</param>
33+
/// <param name="colorType">The color type of the pixel data.</param>
2934
/// <param name="predictor">The tiff predictor used.</param>
30-
public DeflateTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffPredictor predictor)
35+
/// <param name="isBigEndian">if set to <c>true</c> decodes the pixel data as big endian, otherwise as little endian.</param>
36+
public DeflateTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian)
3137
: base(memoryAllocator, width, bitsPerPixel, predictor)
3238
{
39+
this.colorType = colorType;
40+
this.isBigEndian = isBigEndian;
3341
}
3442

3543
/// <inheritdoc/>
@@ -62,7 +70,7 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, Spa
6270

6371
if (this.Predictor == TiffPredictor.Horizontal)
6472
{
65-
HorizontalPredictor.Undo(buffer, this.Width, this.BitsPerPixel);
73+
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
6674
}
6775
}
6876

src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwTiffCompression.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using SixLabors.ImageSharp.Formats.Tiff.Constants;
6+
using SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation;
67
using SixLabors.ImageSharp.IO;
78
using SixLabors.ImageSharp.Memory;
89

@@ -13,16 +14,24 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
1314
/// </summary>
1415
internal class LzwTiffCompression : TiffBaseDecompressor
1516
{
17+
private readonly bool isBigEndian;
18+
19+
private readonly TiffColorType colorType;
20+
1621
/// <summary>
1722
/// Initializes a new instance of the <see cref="LzwTiffCompression" /> class.
1823
/// </summary>
1924
/// <param name="memoryAllocator">The memoryAllocator to use for buffer allocations.</param>
2025
/// <param name="width">The image width.</param>
2126
/// <param name="bitsPerPixel">The bits used per pixel.</param>
27+
/// <param name="colorType">The color type of the pixel data.</param>
2228
/// <param name="predictor">The tiff predictor used.</param>
23-
public LzwTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffPredictor predictor)
29+
/// <param name="isBigEndian">if set to <c>true</c> decodes the pixel data as big endian, otherwise as little endian.</param>
30+
public LzwTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian)
2431
: base(memoryAllocator, width, bitsPerPixel, predictor)
2532
{
33+
this.colorType = colorType;
34+
this.isBigEndian = isBigEndian;
2635
}
2736

2837
/// <inheritdoc/>
@@ -33,7 +42,7 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, Spa
3342

3443
if (this.Predictor == TiffPredictor.Horizontal)
3544
{
36-
HorizontalPredictor.Undo(buffer, this.Width, this.BitsPerPixel);
45+
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
3746
}
3847
}
3948

0 commit comments

Comments
 (0)