Browse Source

Merge branch 'main' into bp/modeScoreArm

pull/2356/head
Brian Popow 3 years ago
committed by GitHub
parent
commit
344cca9f0f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/ImageSharp/Formats/DecoderOptions.cs
  2. 8
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

14
src/ImageSharp/Formats/DecoderOptions.cs

@ -15,15 +15,25 @@ public sealed class DecoderOptions
private uint maxFrames = int.MaxValue;
// Used by the FileProvider in the unit tests to set the configuration on the fly.
#pragma warning disable IDE0032 // Use auto property
private Configuration configuration = Configuration.Default;
#pragma warning restore IDE0032 // Use auto property
/// <summary>
/// Gets the shared default general decoder options instance.
/// Used internally to reduce allocations for default decoding operations.
/// </summary>
internal static DecoderOptions Default { get; } = LazyOptions.Value;
/// <summary>
/// Gets a custom configuration instance to be used by the image processing pipeline.
/// </summary>
public Configuration Configuration { get; internal set; } = Configuration.Default;
#pragma warning disable IDE0032 // Use auto property
#pragma warning disable RCS1085 // Use auto-implemented property.
public Configuration Configuration { get => this.configuration; init => this.configuration = value; }
#pragma warning restore RCS1085 // Use auto-implemented property.
#pragma warning restore IDE0032 // Use auto property
/// <summary>
/// Gets the target size to decode the image into. Scaling should use an operation equivalent to <see cref="ResizeMode.Max"/>.
@ -44,4 +54,6 @@ public sealed class DecoderOptions
/// Gets the maximum number of image frames to decode, inclusive.
/// </summary>
public uint MaxFrames { get => this.maxFrames; init => this.maxFrames = Math.Clamp(value, 1, int.MaxValue); }
internal void SetConfiguration(Configuration configuration) => this.configuration = configuration;
}

8
tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

@ -207,7 +207,7 @@ public abstract partial class TestImageProvider<TPixel> : IXunitSerializable
Guard.NotNull(decoder, nameof(decoder));
Guard.NotNull(options, nameof(options));
options.Configuration = this.Configuration;
options.SetConfiguration(this.Configuration);
// Used in small subset of decoder tests, no caching.
// TODO: Check Path here. Why combined?
@ -244,7 +244,7 @@ public abstract partial class TestImageProvider<TPixel> : IXunitSerializable
Guard.NotNull(decoder, nameof(decoder));
Guard.NotNull(options, nameof(options));
options.GeneralOptions.Configuration = this.Configuration;
options.GeneralOptions.SetConfiguration(this.Configuration);
// Used in small subset of decoder tests, no caching.
// TODO: Check Path here. Why combined?
@ -268,7 +268,7 @@ public abstract partial class TestImageProvider<TPixel> : IXunitSerializable
private Image<TPixel> DecodeImage(IImageDecoder decoder, DecoderOptions options)
{
options.Configuration = this.Configuration;
options.SetConfiguration(this.Configuration);
var testFile = TestFile.Create(this.FilePath);
using Stream stream = new MemoryStream(testFile.Bytes);
@ -278,7 +278,7 @@ public abstract partial class TestImageProvider<TPixel> : IXunitSerializable
private Image<TPixel> DecodeImage<T>(ISpecializedImageDecoder<T> decoder, T options)
where T : class, ISpecializedDecoderOptions, new()
{
options.GeneralOptions.Configuration = this.Configuration;
options.GeneralOptions.SetConfiguration(this.Configuration);
var testFile = TestFile.Create(this.FilePath);
using Stream stream = new MemoryStream(testFile.Bytes);

Loading…
Cancel
Save