//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Formats
{
using System.Text;
///
/// Encapsulates the gif decoder options.
///
public sealed class GifDecoderOptions : DecoderOptions, IGifDecoderOptions
{
private static readonly Encoding DefaultEncoding = Encoding.GetEncoding("ASCII");
///
/// Initializes a new instance of the class.
///
public GifDecoderOptions()
{
this.InitializeWithDefaults();
}
///
/// Initializes a new instance of the class.
///
/// The options for the decoder.
private GifDecoderOptions(IDecoderOptions options)
: base(options)
{
this.InitializeWithDefaults();
}
///
/// Gets or sets the encoding that should be used when reading comments.
///
public Encoding TextEncoding { get; set; }
///
/// Converts the options to a instance with a cast
/// or by creating a new instance with the specfied options.
///
/// The options for the decoder.
/// The options for the png decoder.
internal static IGifDecoderOptions Create(IDecoderOptions options)
{
IGifDecoderOptions gifOptions = options as IGifDecoderOptions;
if (gifOptions != null)
{
return gifOptions;
}
return new GifDecoderOptions(options);
}
private void InitializeWithDefaults()
{
this.TextEncoding = DefaultEncoding;
}
}
}