Browse Source

Use constructor instead of property to get the default decoder options.

af/merge-core
Dirk Lemstra 9 years ago
committed by Dirk Lemstra
parent
commit
966648ed0c
  1. 2
      src/ImageSharp.Formats.Gif/GifDecoderCore.cs
  2. 2
      src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs
  3. 28
      src/ImageSharp/Formats/DecoderOptions.cs

2
src/ImageSharp.Formats.Gif/GifDecoderCore.cs

@ -73,7 +73,7 @@ namespace ImageSharp.Formats
/// <param name="options">The decoder options.</param>
public GifDecoderCore(IDecoderOptions options)
{
this.options = options ?? DecoderOptions.Default;
this.options = options ?? new DecoderOptions();
}
/// <summary>

2
src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs

@ -93,7 +93,7 @@ namespace ImageSharp.Formats
/// <param name="options">The decoder options.</param>
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];

28
src/ImageSharp/Formats/DecoderOptions.cs

@ -11,22 +11,36 @@ namespace ImageSharp
public class DecoderOptions : IDecoderOptions
{
/// <summary>
/// Gets the default decoder options
/// Initializes a new instance of the <see cref="DecoderOptions"/> class.
/// </summary>
public static DecoderOptions Default
public DecoderOptions()
{
get
this.InitializeWithDefaults();
}
/// <summary>
/// Initializes a new instance of the <see cref="DecoderOptions"/> class.
/// </summary>
/// <param name="options">The decoder options</param>
protected DecoderOptions(IDecoderOptions options)
{
if (options == null)
{
return new DecoderOptions()
{
IgnoreMetadata = false
};
this.InitializeWithDefaults();
return;
}
this.IgnoreMetadata = options.IgnoreMetadata;
}
/// <summary>
/// Gets or sets a value indicating whether the metadata should be ignored when the image is being decoded.
/// </summary>
public bool IgnoreMetadata { get; set; }
private void InitializeWithDefaults()
{
this.IgnoreMetadata = false;
}
}
}

Loading…
Cancel
Save