Browse Source

Fix test file

pull/2276/head
James Jackson-South 3 years ago
parent
commit
2145794271
  1. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs
  2. 1
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  3. 34
      tests/ImageSharp.Tests/TestFile.cs

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs

@ -253,7 +253,7 @@ public partial class JpegDecoderTests
DecoderOptions options = new() { SkipMetadata = ignoreMetadata };
// Snake.jpg has both Exif and ICC profiles defined:
var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake);
TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake);
using Image<Rgba32> image = testFile.CreateRgba32Image(JpegDecoder, options);
if (ignoreMetadata)

1
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -8,7 +8,6 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;

34
tests/ImageSharp.Tests/TestFile.cs

@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License.
using System.Collections.Concurrent;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
@ -24,16 +23,6 @@ public sealed class TestFile
// ReSharper disable once InconsistentNaming
private static readonly Lazy<string> InputImagesDirectoryValue = new(() => TestEnvironment.InputImagesDirectoryFullPath);
/// <summary>
/// The image (lazy initialized value)
/// </summary>
private volatile Image<Rgba32> image;
/// <summary>
/// Used to ensure image loading is threadsafe.
/// </summary>
private readonly object syncLock = new();
/// <summary>
/// The image bytes
/// </summary>
@ -65,25 +54,6 @@ public sealed class TestFile
/// </summary>
public string FileNameWithoutExtension => Path.GetFileNameWithoutExtension(this.FullPath);
/// <summary>
/// Gets the image with lazy initialization.
/// </summary>
private Image<Rgba32> Image
{
get
{
if (this.image is null)
{
lock (this.syncLock)
{
this.image ??= ImageSharp.Image.Load<Rgba32>(this.Bytes);
}
}
return this.image;
}
}
/// <summary>
/// Gets the input image directory.
/// </summary>
@ -137,8 +107,7 @@ public sealed class TestFile
/// <returns>
/// The <see cref="Image{Rgba32}"/>.
/// </returns>
public Image<Rgba32> CreateRgba32Image()
=> this.Image.Clone();
public Image<Rgba32> CreateRgba32Image() => Image.Load<Rgba32>(this.Bytes);
/// <summary>
/// Creates a new <see cref="Rgba32"/> image.
@ -160,7 +129,6 @@ public sealed class TestFile
/// </returns>
public Image<Rgba32> CreateRgba32Image(IImageDecoder decoder, DecoderOptions options)
{
options.Configuration = this.Image.GetConfiguration();
using MemoryStream stream = new(this.Bytes);
return decoder.Decode<Rgba32>(options, stream);
}

Loading…
Cancel
Save