mirror of https://github.com/SixLabors/ImageSharp
26 changed files with 391 additions and 194 deletions
@ -0,0 +1,43 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Defines the contract for all image encoders that allow encoding animation sequences.
|
||||
|
/// </summary>
|
||||
|
public interface IAnimatedImageEncoder |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the default background color of the canvas when animating in supported encoders.
|
||||
|
/// This color may be used to fill the unused space on the canvas around the frames,
|
||||
|
/// as well as the transparent pixels of the first frame.
|
||||
|
/// The background color is also used when a frame disposal mode is <see cref="FrameDisposalMode.RestoreToBackground"/>.
|
||||
|
/// </summary>
|
||||
|
Color? BackgroundColor { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the number of times any animation is repeated in supported encoders.
|
||||
|
/// </summary>
|
||||
|
ushort? RepeatCount { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a value indicating whether the root frame is shown as part of the animated sequence in supported encoders.
|
||||
|
/// </summary>
|
||||
|
bool? AnimateRootFrame { get; } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Acts as a base class for all image encoders that allow encoding animation sequences.
|
||||
|
/// </summary>
|
||||
|
public abstract class AnimatedImageEncoder : ImageEncoder, IAnimatedImageEncoder |
||||
|
{ |
||||
|
/// <inheritdoc/>
|
||||
|
public Color? BackgroundColor { get; init; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public ushort? RepeatCount { get; init; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public bool? AnimateRootFrame { get; init; } = true; |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
// Copyright (c) Six Labors.
|
||||
|
// Licensed under the Six Labors Split License.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.Processing.Processors.Quantization; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Defines the contract for all image encoders that allow color palette generation via quantization.
|
||||
|
/// </summary>
|
||||
|
public interface IQuantizingImageEncoder |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the quantizer used to generate the color palette.
|
||||
|
/// </summary>
|
||||
|
IQuantizer? Quantizer { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the <see cref="IPixelSamplingStrategy"/> used for quantization when building color palettes.
|
||||
|
/// </summary>
|
||||
|
IPixelSamplingStrategy PixelSamplingStrategy { get; } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Acts as a base class for all image encoders that allow color palette generation via quantization.
|
||||
|
/// </summary>
|
||||
|
public abstract class QuantizingImageEncoder : ImageEncoder, IQuantizingImageEncoder |
||||
|
{ |
||||
|
/// <inheritdoc/>
|
||||
|
public IQuantizer? Quantizer { get; init; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public IPixelSamplingStrategy PixelSamplingStrategy { get; init; } = new DefaultPixelSamplingStrategy(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Acts as a base class for all image encoders that allow color palette generation via quantization when
|
||||
|
/// encoding animation sequences.
|
||||
|
/// </summary>
|
||||
|
public abstract class QuantizingAnimatedImageEncoder : QuantizingImageEncoder, IAnimatedImageEncoder |
||||
|
{ |
||||
|
/// <inheritdoc/>
|
||||
|
public Color? BackgroundColor { get; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public ushort? RepeatCount { get; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public bool? AnimateRootFrame { get; } |
||||
|
} |
||||
@ -1,22 +0,0 @@ |
|||||
// Copyright (c) Six Labors.
|
|
||||
// Licensed under the Six Labors Split License.
|
|
||||
|
|
||||
using SixLabors.ImageSharp.Processing.Processors.Quantization; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Formats; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Acts as a base class for all image encoders that allow color palette generation via quantization.
|
|
||||
/// </summary>
|
|
||||
public abstract class QuantizingImageEncoder : ImageEncoder |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Gets the quantizer used to generate the color palette.
|
|
||||
/// </summary>
|
|
||||
public IQuantizer? Quantizer { get; init; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets the <see cref="IPixelSamplingStrategy"/> used for quantization when building color palettes.
|
|
||||
/// </summary>
|
|
||||
public IPixelSamplingStrategy PixelSamplingStrategy { get; init; } = new DefaultPixelSamplingStrategy(); |
|
||||
} |
|
||||
Loading…
Reference in new issue