Browse Source

Add exr decoder tests

pull/3096/head
Brian Popow 4 years ago
parent
commit
ce21f1afaa
  1. 4
      src/ImageSharp/Configuration.cs
  2. 54
      tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs
  3. 8
      tests/ImageSharp.Tests/TestImages.cs
  4. 6
      tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs
  5. 3
      tests/Images/Input/Exr/Calliphora_rle.exr
  6. 3
      tests/Images/Input/Exr/Calliphora_uncompressed.exr
  7. 3
      tests/Images/Input/Exr/Calliphora_zip.exr
  8. 3
      tests/Images/Input/Exr/Calliphora_zips.exr

4
src/ImageSharp/Configuration.cs

@ -213,6 +213,7 @@ public sealed class Configuration
/// <see cref="TgaConfigurationModule"/>.
/// <see cref="TiffConfigurationModule"/>.
/// <see cref="WebpConfigurationModule"/>.
/// <see cref="ExrConfigurationModule"/>.
/// </summary>
/// <returns>The default configuration of <see cref="Configuration"/>.</returns>
internal static Configuration CreateDefaultInstance() => new(
@ -223,5 +224,6 @@ public sealed class Configuration
new PbmConfigurationModule(),
new TgaConfigurationModule(),
new TiffConfigurationModule(),
new WebpConfigurationModule());
new WebpConfigurationModule(),
new ExrConfigurationModule());
}

54
tests/ImageSharp.Tests/Formats/Exr/ExrDecoderTests.cs

@ -0,0 +1,54 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats.OpenExr;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Tests.Formats.Exr;
[Trait("Format", "Exr")]
[ValidateDisposedMemoryAllocations]
public class ExrDecoderTests
{
private static ExrDecoder ExrDecoder => new();
[Theory]
[WithFile(TestImages.Exr.Uncompressed, PixelTypes.Rgba32)]
public void ExrDecoder_CanDecode_Uncompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(ExrDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider);
}
[Theory]
[WithFile(TestImages.Exr.Zip, PixelTypes.Rgba32)]
public void ExrDecoder_CanDecode_ZipCompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(ExrDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider);
}
[Theory]
[WithFile(TestImages.Exr.Zips, PixelTypes.Rgba32)]
public void ExrDecoder_CanDecode_ZipsCompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(ExrDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider);
}
[Theory]
[WithFile(TestImages.Exr.Rle, PixelTypes.Rgba32)]
public void ExrDecoder_CanDecode_RunLengthCompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(ExrDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider);
}
}

8
tests/ImageSharp.Tests/TestImages.cs

@ -998,4 +998,12 @@ public static class TestImages
public const string RgbPlainNormalized = "Pbm/rgb_plain_normalized.ppm";
public const string RgbPlainMagick = "Pbm/rgb_plain_magick.ppm";
}
public static class Exr
{
public const string Uncompressed = "Exr/Calliphora_uncompressed.exr";
public const string Zip = "Exr/Calliphora_zip.exr";
public const string Zips = "Exr/Calliphora_zips.exr";
public const string Rle = "Exr/Calliphora_rle.exr";
}
}

6
tests/ImageSharp.Tests/TestUtilities/TestEnvironment.Formats.cs

@ -5,6 +5,7 @@ using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.OpenExr;
using SixLabors.ImageSharp.Formats.Pbm;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Tga;
@ -59,12 +60,13 @@ public static partial class TestEnvironment
new PbmConfigurationModule(),
new TgaConfigurationModule(),
new WebpConfigurationModule(),
new TiffConfigurationModule());
new TiffConfigurationModule(),
new ExrConfigurationModule());
IImageEncoder pngEncoder = IsWindows ? SystemDrawingReferenceEncoder.Png : new ImageSharpPngEncoderWithDefaultConfiguration();
IImageEncoder bmpEncoder = IsWindows ? SystemDrawingReferenceEncoder.Bmp : new BmpEncoder();
// Magick codecs should work on all platforms
// Magick codecs should work on all platforms.
cfg.ConfigureCodecs(
PngFormat.Instance,
MagickReferenceDecoder.Instance,

3
tests/Images/Input/Exr/Calliphora_rle.exr

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6302e72676f5574b8a9dde7e4385cff1c115e9833b630118328b88aea07e31d0
size 4098454

3
tests/Images/Input/Exr/Calliphora_uncompressed.exr

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71613ff5972fa9e7b405ac944d159d1791ad229f5560da616438c9d718eafd24
size 5798633

3
tests/Images/Input/Exr/Calliphora_zip.exr

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:92c78a7cf9fce29e725511acadf49f0f784914da5bef55b0e0c4e75ba09c3a75
size 2652397

3
tests/Images/Input/Exr/Calliphora_zips.exr

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