Browse Source

Only compare first frame in old jpeg compression test

pull/2266/head
Brian Popow 4 years ago
parent
commit
be1ee582c5
  1. 15
      tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
  2. 13
      tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

15
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs

@ -668,7 +668,20 @@ public class TiffDecoderTests : TiffDecoderBaseTester
[WithFile(RgbOldJpegCompressed, PixelTypes.Rgba32)]
[WithFile(YCbCrOldJpegCompressed, PixelTypes.Rgba32)]
public void TiffDecoder_CanDecode_OldJpegCompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false);
where TPixel : unmanaged, IPixel<TPixel>
{
DecoderOptions decoderOptions = new()
{
MaxFrames = 1
};
using Image<TPixel> image = provider.GetImage(TiffDecoder, decoderOptions);
image.DebugSave(provider);
image.CompareToOriginal(
provider,
ImageComparer.Tolerant(0.001f),
ReferenceDecoder,
decoderOptions);
}
[Theory]
[WithFile(WebpCompressed, PixelTypes.Rgba32)]

13
tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs

@ -518,7 +518,8 @@ public static class TestImageExtensions
this Image<TPixel> image,
ITestImageProvider provider,
ImageComparer comparer,
IImageDecoder referenceDecoder = null)
IImageDecoder referenceDecoder = null,
DecoderOptions referenceDecoderOptions = null)
where TPixel : unmanaged, IPixel<TPixel>
{
string path = TestImageProvider<TPixel>.GetFilePathOrNull(provider);
@ -527,12 +528,12 @@ public static class TestImageExtensions
throw new InvalidOperationException("CompareToOriginal() works only with file providers!");
}
var testFile = TestFile.Create(path);
TestFile testFile = TestFile.Create(path);
referenceDecoder ??= TestEnvironment.GetReferenceDecoder(path);
using var stream = new MemoryStream(testFile.Bytes);
using (Image<TPixel> original = referenceDecoder.Decode<TPixel>(DecoderOptions.Default, stream, default))
using MemoryStream stream = new(testFile.Bytes);
using (Image<TPixel> original = referenceDecoder.Decode<TPixel>(referenceDecoderOptions ?? DecoderOptions.Default, stream, default))
{
comparer.VerifySimilarity(original, image);
}
@ -553,11 +554,11 @@ public static class TestImageExtensions
throw new InvalidOperationException("CompareToOriginal() works only with file providers!");
}
var testFile = TestFile.Create(path);
TestFile testFile = TestFile.Create(path);
referenceDecoder ??= TestEnvironment.GetReferenceDecoder(path);
using var stream = new MemoryStream(testFile.Bytes);
using MemoryStream stream = new(testFile.Bytes);
using (Image<TPixel> original = referenceDecoder.Decode<TPixel>(DecoderOptions.Default, stream, default))
{
comparer.VerifySimilarity(original, image);

Loading…
Cancel
Save