|
| 1 | +// Copyright (c) Six Labors. |
| 2 | +// Licensed under the Six Labors Split License. |
| 3 | + |
| 4 | +namespace SixLabors.ImageSharp.Formats; |
| 5 | +internal class AnimatedImageFrameMetadata |
| 6 | +{ |
| 7 | + /// <summary> |
| 8 | + /// Gets or sets the frame color table. |
| 9 | + /// </summary> |
| 10 | + public ReadOnlyMemory<Color>? ColorTable { get; set; } |
| 11 | + |
| 12 | + /// <summary> |
| 13 | + /// Gets or sets the frame color table mode. |
| 14 | + /// </summary> |
| 15 | + public FrameColorTableMode ColorTableMode { get; set; } |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// Gets or sets the duration of the frame. |
| 19 | + /// </summary> |
| 20 | + public TimeSpan Duration { get; set; } |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// Gets or sets the frame alpha blending mode. |
| 24 | + /// </summary> |
| 25 | + public FrameBlendMode BlendMode { get; set; } |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Gets or sets the frame disposal mode. |
| 29 | + /// </summary> |
| 30 | + public FrameDisposalMode DisposalMode { get; set; } |
| 31 | +} |
| 32 | + |
| 33 | +#pragma warning disable SA1201 // Elements should appear in the correct order |
| 34 | +internal enum FrameBlendMode |
| 35 | +#pragma warning restore SA1201 // Elements should appear in the correct order |
| 36 | +{ |
| 37 | + /// <summary> |
| 38 | + /// Do not blend. Render the current frame on the canvas by overwriting the rectangle covered by the current frame. |
| 39 | + /// </summary> |
| 40 | + Source = 0, |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Blend the current frame with the previous frame in the animation sequence within the rectangle covered |
| 44 | + /// by the current frame. |
| 45 | + /// If the current has any transparent areas, the corresponding areas of the previous frame will be visible |
| 46 | + /// through these transparent regions. |
| 47 | + /// </summary> |
| 48 | + Over = 1 |
| 49 | +} |
| 50 | + |
| 51 | +internal enum FrameDisposalMode |
| 52 | +{ |
| 53 | + /// <summary> |
| 54 | + /// No disposal specified. |
| 55 | + /// The decoder is not required to take any action. |
| 56 | + /// </summary> |
| 57 | + Unspecified = 0, |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// Do not dispose. The current frame is not disposed of, or in other words, not cleared or altered when moving to |
| 61 | + /// the next frame. This means that the next frame is drawn over the current frame, and if the next frame contains |
| 62 | + /// transparency, the previous frame will be visible through these transparent areas. |
| 63 | + /// </summary> |
| 64 | + DoNotDispose = 1, |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Restore to background color. When transitioning to the next frame, the area occupied by the current frame is |
| 68 | + /// filled with the background color specified in the image metadata. |
| 69 | + /// This effectively erases the current frame by replacing it with the background color before the next frame is displayed. |
| 70 | + /// </summary> |
| 71 | + RestoreToBackground = 2, |
| 72 | + |
| 73 | + /// <summary> |
| 74 | + /// Restore to previous. This method restores the area affected by the current frame to what it was before the |
| 75 | + /// current frame was displayed. It essentially "undoes" the current frame, reverting to the state of the image |
| 76 | + /// before the frame was displayed, then the next frame is drawn. This is useful for animations where only a small |
| 77 | + /// part of the image changes from frame to frame. |
| 78 | + /// </summary> |
| 79 | + RestoreToPrevious = 3 |
| 80 | +} |
| 81 | + |
| 82 | +internal enum FrameColorTableMode |
| 83 | +{ |
| 84 | + /// <summary> |
| 85 | + /// The frame uses the shared color table specified by the image metadata. |
| 86 | + /// </summary> |
| 87 | + Global, |
| 88 | + |
| 89 | + /// <summary> |
| 90 | + /// The frame uses a color table specified by the frame metadata. |
| 91 | + /// </summary> |
| 92 | + Local |
| 93 | +} |
0 commit comments