diff --git a/src/ImageSharp.Formats.Gif/GifDecoderCore.cs b/src/ImageSharp.Formats.Gif/GifDecoderCore.cs index 50d4da0ebc..2a0d53bde7 100644 --- a/src/ImageSharp.Formats.Gif/GifDecoderCore.cs +++ b/src/ImageSharp.Formats.Gif/GifDecoderCore.cs @@ -73,7 +73,7 @@ namespace ImageSharp.Formats /// The decoder options. public GifDecoderCore(IDecoderOptions options) { - this.options = options ?? DecoderOptions.Default; + this.options = options ?? new DecoderOptions(); } /// diff --git a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs index 19b3df5368..f1b85fa0bf 100644 --- a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs @@ -93,7 +93,7 @@ namespace ImageSharp.Formats /// The decoder options. public JpegDecoderCore(IDecoderOptions options) { - this.options = options ?? DecoderOptions.Default; + this.options = options ?? new DecoderOptions(); this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees(); this.QuantizationTables = new Block8x8F[MaxTq + 1]; this.Temp = new byte[2 * Block8x8F.ScalarCount]; diff --git a/src/ImageSharp/Formats/DecoderOptions.cs b/src/ImageSharp/Formats/DecoderOptions.cs index a9bb152f12..4755ddcb66 100644 --- a/src/ImageSharp/Formats/DecoderOptions.cs +++ b/src/ImageSharp/Formats/DecoderOptions.cs @@ -11,22 +11,36 @@ namespace ImageSharp public class DecoderOptions : IDecoderOptions { /// - /// Gets the default decoder options + /// Initializes a new instance of the class. /// - public static DecoderOptions Default + public DecoderOptions() { - get + this.InitializeWithDefaults(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The decoder options + protected DecoderOptions(IDecoderOptions options) + { + if (options == null) { - return new DecoderOptions() - { - IgnoreMetadata = false - }; + this.InitializeWithDefaults(); + return; } + + this.IgnoreMetadata = options.IgnoreMetadata; } /// /// Gets or sets a value indicating whether the metadata should be ignored when the image is being decoded. /// public bool IgnoreMetadata { get; set; } + + private void InitializeWithDefaults() + { + this.IgnoreMetadata = false; + } } }