-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b33209c
commit 1b0b877
Showing
11 changed files
with
349 additions
and
335 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
37 changes: 37 additions & 0 deletions
37
src/ImageSharp/Formats/Webp/Chunks/WebpAnimationParameter.cs
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,37 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Buffers.Binary; | ||
using SixLabors.ImageSharp.Common.Helpers; | ||
|
||
namespace SixLabors.ImageSharp.Formats.Webp.Chunks; | ||
|
||
internal readonly struct WebpAnimationParameter | ||
{ | ||
public WebpAnimationParameter(uint background, ushort loopCount) | ||
{ | ||
this.Background = background; | ||
this.LoopCount = loopCount; | ||
} | ||
|
||
/// <summary> | ||
/// Gets default background color of the canvas in [Blue, Green, Red, Alpha] byte order. | ||
/// 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 the Disposal method is 1. | ||
/// </summary> | ||
public uint Background { get; } | ||
|
||
/// <summary> | ||
/// Gets number of times to loop the animation. If it is 0, this means infinitely. | ||
/// </summary> | ||
public ushort LoopCount { get; } | ||
|
||
public void WriteTo(Stream stream) | ||
{ | ||
Span<byte> buffer = stackalloc byte[6]; | ||
BinaryPrimitives.WriteUInt32LittleEndian(buffer[..4], this.Background); | ||
BinaryPrimitives.WriteUInt16LittleEndian(buffer[4..], this.LoopCount); | ||
RiffHelper.WriteChunk(stream, (uint)WebpChunkType.AnimationParameter, buffer); | ||
} | ||
} |
Oops, something went wrong.