Skip to content

Undo horizontal prediction for each tile row in case of tiled tiff's #2878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f72be91
Undo horizontal prediction for each tile row in case of tiled tiff's
brianpopow Feb 2, 2025
e186c52
Add test case for tiled tiff, deflate compressed with predictor
brianpopow Feb 3, 2025
787e04d
Add test case for tiled tiff, deflate compressed with predictor and c…
brianpopow Feb 4, 2025
e3c7471
Add test case for tiled gray tiff, deflate compressed with predictor
brianpopow Feb 6, 2025
f11fbc1
Add test cases for tiled 16 bit gray tiff's
brianpopow Feb 8, 2025
47c6755
Add test cases for tiled 32 bit gray tiff's
brianpopow Feb 9, 2025
97133fe
Add test cases for tiled tiff, deflate compressed with predictor and …
brianpopow Feb 9, 2025
f804ca2
Add test cases for tiled tiff, deflate compressed with predictor and …
brianpopow Feb 9, 2025
dacb713
Add test cases for tiled tiff, deflate compressed with predictor and …
brianpopow Feb 10, 2025
dec1dc1
Add test cases for tiled tiff, deflate compressed with predictor and …
brianpopow Feb 11, 2025
9954f50
Merge remote-tracking branch 'origin/main' into bp/Issue2877
brianpopow Feb 14, 2025
71f7d86
Add method UndoTile in HorizontalPredictor
brianpopow Feb 19, 2025
5cfa2bc
Enable 32 bits per channel decoding for MagickReferenceDecoder
brianpopow Feb 19, 2025
0a52ee7
Try fix build issue with ubuntu latest and net9.0
brianpopow Feb 20, 2025
7a5be72
Add test cases for tiled lzw compressed images
brianpopow Feb 20, 2025
8f97280
Add tiled rgba 16 bit each channel test files
brianpopow Feb 20, 2025
18f8de9
Do not ignore tileHeight when undoing horizontal predictor
brianpopow Feb 22, 2025
23cfdd2
Better test images for tiled tiff: tile width and height is not the same
brianpopow Feb 23, 2025
85c7ed2
Merge branch 'main' into bp/Issue2877
JimBobSquarePants Apr 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor

private readonly TiffColorType colorType;

private readonly bool isTiled;

private readonly int tileWidth;

private readonly int tileHeight;

/// <summary>
/// Initializes a new instance of the <see cref="DeflateTiffCompression" /> class.
/// </summary>
Expand All @@ -31,11 +37,17 @@ internal sealed class DeflateTiffCompression : TiffBaseDecompressor
/// <param name="colorType">The color type of the pixel data.</param>
/// <param name="predictor">The tiff predictor used.</param>
/// <param name="isBigEndian">if set to <c>true</c> decodes the pixel data as big endian, otherwise as little endian.</param>
public DeflateTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian)
/// <param name="isTiled">Flag indicates, if the image is a tiled image.</param>
/// <param name="tileWidth">Number of pixels in a tile row.</param>
/// <param name="tileHeight">Number of rows in a tile.</param>
public DeflateTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian, bool isTiled, int tileWidth, int tileHeight)
: base(memoryAllocator, width, bitsPerPixel, predictor)
{
this.colorType = colorType;
this.isBigEndian = isBigEndian;
this.isTiled = isTiled;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
}

/// <inheritdoc/>
Expand Down Expand Up @@ -70,7 +82,15 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int

if (this.Predictor == TiffPredictor.Horizontal)
{
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
if (this.isTiled)
{
// When the image is tiled, undoing the horizontal predictor will be done for each tile row.
HorizontalPredictor.UndoTile(buffer, this.tileWidth, this.tileHeight, this.colorType, this.isBigEndian);
}
else
{
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor

private readonly TiffColorType colorType;

private readonly bool isTiled;

private readonly int tileWidth;

private readonly int tileHeight;

/// <summary>
/// Initializes a new instance of the <see cref="LzwTiffCompression" /> class.
/// </summary>
Expand All @@ -26,11 +32,17 @@ internal sealed class LzwTiffCompression : TiffBaseDecompressor
/// <param name="colorType">The color type of the pixel data.</param>
/// <param name="predictor">The tiff predictor used.</param>
/// <param name="isBigEndian">if set to <c>true</c> decodes the pixel data as big endian, otherwise as little endian.</param>
public LzwTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian)
/// <param name="isTiled">Flag indicates, if the image is a tiled image.</param>
/// <param name="tileWidth">Number of pixels in a tile row.</param>
/// <param name="tileHeight">Number of rows in a tile.</param>
public LzwTiffCompression(MemoryAllocator memoryAllocator, int width, int bitsPerPixel, TiffColorType colorType, TiffPredictor predictor, bool isBigEndian, bool isTiled, int tileWidth, int tileHeight)
: base(memoryAllocator, width, bitsPerPixel, predictor)
{
this.colorType = colorType;
this.isBigEndian = isBigEndian;
this.isTiled = isTiled;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
}

/// <inheritdoc/>
Expand All @@ -41,7 +53,15 @@ protected override void Decompress(BufferedReadStream stream, int byteCount, int

if (this.Predictor == TiffPredictor.Horizontal)
{
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
if (this.isTiled)
{
// When the image is tiled, undoing the horizontal predictor will be done for each tile row.
HorizontalPredictor.UndoTile(buffer, this.tileWidth, this.tileHeight, this.colorType, this.isBigEndian);
}
else
{
HorizontalPredictor.Undo(buffer, this.Width, this.colorType, this.isBigEndian);
}
}
}

Expand Down
Loading
Loading