Browse Source
Merge pull request #1723 from SixLabors/bp/fixPlanarDecoding
Fix issue calculating the stripIndex for planar tiff's
pull/1726/head
Brian Popow
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
16 additions and
2 deletions
-
src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
-
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Tiff/flower-rgb-planar-08-15strips.tiff
-
tests/Images/Input/Tiff/flower-rgb-planar-08-6strips.tiff
|
|
@ -272,11 +272,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff |
|
|
{ |
|
|
{ |
|
|
int stripHeight = i < stripsPerPlane - 1 || frame.Height % rowsPerStrip == 0 ? rowsPerStrip : frame.Height % rowsPerStrip; |
|
|
int stripHeight = i < stripsPerPlane - 1 || frame.Height % rowsPerStrip == 0 ? rowsPerStrip : frame.Height % rowsPerStrip; |
|
|
|
|
|
|
|
|
|
|
|
int stripIndex = i; |
|
|
for (int planeIndex = 0; planeIndex < stripsPerPixel; planeIndex++) |
|
|
for (int planeIndex = 0; planeIndex < stripsPerPixel; planeIndex++) |
|
|
{ |
|
|
{ |
|
|
int stripIndex = (i * stripsPerPixel) + planeIndex; |
|
|
|
|
|
|
|
|
|
|
|
decompressor.Decompress(this.inputStream, (uint)stripOffsets[stripIndex], (uint)stripByteCounts[stripIndex], stripBuffers[planeIndex].GetSpan()); |
|
|
decompressor.Decompress(this.inputStream, (uint)stripOffsets[stripIndex], (uint)stripByteCounts[stripIndex], stripBuffers[planeIndex].GetSpan()); |
|
|
|
|
|
stripIndex += stripsPerPlane; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
colorDecoder.Decode(stripBuffers, pixels, 0, rowsPerStrip * i, frame.Width, stripHeight); |
|
|
colorDecoder.Decode(stripBuffers, pixels, 0, rowsPerStrip * i, frame.Width, stripHeight); |
|
|
|
|
|
@ -84,6 +84,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff |
|
|
public void TiffDecoder_CanDecode_Uncompressed<TPixel>(TestImageProvider<TPixel> provider) |
|
|
public void TiffDecoder_CanDecode_Uncompressed<TPixel>(TestImageProvider<TPixel> provider) |
|
|
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider); |
|
|
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider); |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[WithFile(FlowerRgb888Planar6Strips, PixelTypes.Rgba32)] |
|
|
|
|
|
[WithFile(FlowerRgb888Planar15Strips, PixelTypes.Rgba32)] |
|
|
|
|
|
public void TiffDecoder_Planar<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
|
|
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider); |
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)] |
|
|
[WithFile(Calliphora_PaletteUncompressed, PixelTypes.Rgba32)] |
|
|
[WithFile(PaletteDeflateMultistrip, PixelTypes.Rgba32)] |
|
|
[WithFile(PaletteDeflateMultistrip, PixelTypes.Rgba32)] |
|
|
|
|
|
@ -576,6 +576,8 @@ namespace SixLabors.ImageSharp.Tests |
|
|
public const string FlowerRgb444Planar = "Tiff/flower-rgb-planar-04.tiff"; |
|
|
public const string FlowerRgb444Planar = "Tiff/flower-rgb-planar-04.tiff"; |
|
|
public const string FlowerRgb222Contiguous = "Tiff/flower-rgb-contig-02.tiff"; |
|
|
public const string FlowerRgb222Contiguous = "Tiff/flower-rgb-contig-02.tiff"; |
|
|
public const string FlowerRgb222Planar = "Tiff/flower-rgb-planar-02.tiff"; |
|
|
public const string FlowerRgb222Planar = "Tiff/flower-rgb-planar-02.tiff"; |
|
|
|
|
|
public const string FlowerRgb888Planar6Strips = "Tiff/flower-rgb-planar-08-6strips.tiff"; |
|
|
|
|
|
public const string FlowerRgb888Planar15Strips = "Tiff/flower-rgb-planar-08-15strips.tiff"; |
|
|
public const string Flower2BitGray = "Tiff/flower-minisblack-02.tiff"; |
|
|
public const string Flower2BitGray = "Tiff/flower-minisblack-02.tiff"; |
|
|
public const string Flower2BitPalette = "Tiff/flower-palette-02.tiff"; |
|
|
public const string Flower2BitPalette = "Tiff/flower-palette-02.tiff"; |
|
|
public const string Flower4BitPalette = "Tiff/flower-palette-04.tiff"; |
|
|
public const string Flower4BitPalette = "Tiff/flower-palette-04.tiff"; |
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
|
|
oid sha256:a49cf47fdf2ea43e5cb5a473523e50222fb13ff6a66bda2e4bdd5796f66140d8 |
|
|
|
|
|
size 9770 |
|
|
@ -0,0 +1,3 @@ |
|
|
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
|
|
oid sha256:a49cf47fdf2ea43e5cb5a473523e50222fb13ff6a66bda2e4bdd5796f66140d8 |
|
|
|
|
|
size 9770 |