-
-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2842 from SixLabors/js/normalize-animation-encoder
Normalize Animation Encoders
- Loading branch information
Showing
26 changed files
with
399 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.