Browse Source

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

af/merge-core
Dirk Lemstra 10 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> /// <param name="options">The decoder options.</param>
public GifDecoderCore(IDecoderOptions options) public GifDecoderCore(IDecoderOptions options)
{ {
this.options = options ?? DecoderOptions.Default; this.options = options ?? new DecoderOptions();
} }
/// <summary> /// <summary>

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

@ -93,7 +93,7 @@ namespace ImageSharp.Formats
/// <param name="options">The decoder options.</param> /// <param name="options">The decoder options.</param>
public JpegDecoderCore(IDecoderOptions options) public JpegDecoderCore(IDecoderOptions options)
{ {
this.options = options ?? DecoderOptions.Default; this.options = options ?? new DecoderOptions();
this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees(); this.HuffmanTrees = HuffmanTree.CreateHuffmanTrees();
this.QuantizationTables = new Block8x8F[MaxTq + 1]; this.QuantizationTables = new Block8x8F[MaxTq + 1];
this.Temp = new byte[2 * Block8x8F.ScalarCount]; this.Temp = new byte[2 * Block8x8F.ScalarCount];

28
src/ImageSharp/Formats/DecoderOptions.cs

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

Loading…
Cancel
Save