mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System.IO;
|
|
using SixLabors.ImageSharp.Metadata;
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
namespace SixLabors.ImageSharp.Formats.Gif
|
|
{
|
|
/// <summary>
|
|
/// Decoder for generating an image out of a gif encoded stream.
|
|
/// </summary>
|
|
public sealed class GifDecoder : IImageDecoder, IGifDecoderOptions, IImageInfoDetector
|
|
{
|
|
/// <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; } = false;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the decoding mode for multi-frame images
|
|
/// </summary>
|
|
public FrameDecodingMode DecodingMode { get; set; } = FrameDecodingMode.All;
|
|
|
|
/// <inheritdoc/>
|
|
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
|
|
where TPixel : struct, IPixel<TPixel>
|
|
{
|
|
var decoder = new GifDecoderCore(configuration, this);
|
|
return decoder.Decode<TPixel>(stream);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public IImageInfo Identify(Configuration configuration, Stream stream)
|
|
{
|
|
Guard.NotNull(stream, nameof(stream));
|
|
|
|
var decoder = new GifDecoderCore(configuration, this);
|
|
return decoder.Identify(stream);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
|
|
}
|
|
}
|
|
|