Browse Source

Additional tests for decoding png's with filter

pull/2028/head
Brian Popow 4 years ago
parent
commit
26a742eb92
  1. 6
      tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs
  2. 36
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  3. 18
      tests/ImageSharp.Tests/TestImages.cs
  4. 3
      tests/Images/Input/Png/PaethFilter4Bpp.png
  5. 3
      tests/Images/Input/Png/SubFilter4Bpp.png

6
tests/ImageSharp.Benchmarks/Codecs/Png/DecodeFilteredPng.cs

@ -23,9 +23,9 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
public void ReadImages()
{
this.filter0 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.Filter0));
this.filter1 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.Filter1));
this.filter2 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.Filter2));
this.filter3 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.Filter4));
this.filter1 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.SubFilter3BytesPerPixel));
this.filter2 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.UpFilter));
this.filter3 = File.ReadAllBytes(TestImageFullPath(TestImages.Png.PaethFilter3BytesPerPixel));
this.averageFilter3bpp = File.ReadAllBytes(TestImageFullPath(TestImages.Png.AverageFilter3BytesPerPixel));
this.averageFilter4bpp = File.ReadAllBytes(TestImageFullPath(TestImages.Png.AverageFilter4BytesPerPixel));
}

36
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -112,8 +112,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
}
[Theory]
[WithFile(TestImages.Png.AverageFilter3BytesPerPixel, PixelTypes.Rgba64)]
[WithFile(TestImages.Png.AverageFilter4BytesPerPixel, PixelTypes.Rgba64)]
[WithFile(TestImages.Png.AverageFilter3BytesPerPixel, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.AverageFilter4BytesPerPixel, PixelTypes.Rgba32)]
public void Decode_WithAverageFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
@ -122,6 +122,38 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
image.CompareToOriginal(provider, ImageComparer.Exact);
}
[Theory]
[WithFile(TestImages.Png.SubFilter3BytesPerPixel, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.SubFilter4BytesPerPixel, PixelTypes.Rgba32)]
public void Decode_WithSubFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(PngDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider, ImageComparer.Exact);
}
[Theory]
[WithFile(TestImages.Png.UpFilter, PixelTypes.Rgba32)]
public void Decode_WithUpFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(PngDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider, ImageComparer.Exact);
}
[Theory]
[WithFile(TestImages.Png.PaethFilter3BytesPerPixel, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.PaethFilter4BytesPerPixel, PixelTypes.Rgba32)]
public void Decode_WithPaethFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(PngDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider, ImageComparer.Exact);
}
[Theory]
[WithFile(TestImages.Png.GrayA8Bit, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.Gray1BitTrans, PixelTypes.Rgba32)]

18
tests/ImageSharp.Tests/TestImages.cs

@ -66,12 +66,13 @@ namespace SixLabors.ImageSharp.Tests
// Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
public const string Filter0 = "Png/filter0.png";
public const string Filter1 = "Png/filter1.png";
public const string Filter2 = "Png/filter2.png";
public const string SubFilter3BytesPerPixel = "Png/filter1.png";
public const string SubFilter4BytesPerPixel = "Png/SubFilter4Bpp.png";
public const string UpFilter = "Png/filter2.png";
public const string AverageFilter3BytesPerPixel = "Png/filter3.png";
public const string Filter4 = "Png/filter4.png";
public const string AverageFilter4BytesPerPixel = "Png/AverageFilter4Bpp.png";
public const string PaethFilter3BytesPerPixel = "Png/filter4.png";
public const string PaethFilter4BytesPerPixel = "Png/PaethFilter4Bpp.png";
// Paletted images also from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
public const string PalettedTwoColor = "Png/basn3p01.png";
@ -156,15 +157,6 @@ namespace SixLabors.ImageSharp.Tests
public const string ColorTypeOne = "Png/xc1n0g08.png";
public const string ColorTypeNine = "Png/xc9n2c08.png";
}
public static readonly string[] All =
{
P1, Pd, Blur, Splash, Cross,
Powerpoint, SplashInterlaced, Interlaced,
Filter0, Filter1, Filter2, AverageFilter3BytesPerPixel, Filter4,
FilterVar, VimImage1, VimImage2, VersioningImage1,
VersioningImage2, Ratio4x1, Ratio1x4
};
}
public static class Jpeg

3
tests/Images/Input/Png/PaethFilter4Bpp.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8b2b0a1190854577d5181fe40af61c421d615a1a2727cf9be5ebe727eaafd00d
size 8624

3
tests/Images/Input/Png/SubFilter4Bpp.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:053fac72ff62c66dacb41a6251efa249d5b31567e0222efbf5b1bef912c0bf77
size 13013
Loading…
Cancel
Save