Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename FrameDelay
  • Loading branch information
Poker-sang committed Apr 7, 2025
commit a979b96abc86d5185c17c2bfaf654c27ba88769c
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Ani/AniDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, Cance

ImageFrameMetadata rootFrameMetadata = img.Frames.RootFrame.Metadata;
AniFrameMetadata aniFrameMetadata = rootFrameMetadata.GetAniMetadata();
aniFrameMetadata.Rate = rate == default ? aniMetadata.DisplayRate : rate[i];
aniFrameMetadata.FrameDelay = rate == default ? aniMetadata.DisplayRate : rate[i];
aniFrameMetadata.FrameCount = img.Frames.Count;
aniFrameMetadata.EncodingWidth = encodingWidth;
aniFrameMetadata.EncodingHeight = encodingHeight;
Expand Down Expand Up @@ -201,7 +201,7 @@ protected override ImageInfo Identify(BufferedReadStream stream, CancellationTok

ImageFrameMetadata rootFrameMetadata = imageInfo.FrameMetadataCollection is [var first, ..] ? first : new();
AniFrameMetadata aniFrameMetadata = rootFrameMetadata.GetAniMetadata();
aniFrameMetadata.Rate = rate == default ? aniMetadata.DisplayRate : rate[i];
aniFrameMetadata.FrameDelay = rate == default ? aniMetadata.DisplayRate : rate[i];
aniFrameMetadata.FrameCount = info.FrameMetadataCollection.Count;
aniFrameMetadata.EncodingWidth = type switch
{
Expand Down
10 changes: 5 additions & 5 deletions src/ImageSharp/Formats/Ani/AniFrameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AniFrameMetadata()
/// <summary>
/// Gets or sets the display time for this frame (in 1/60 seconds)
/// </summary>
public uint Rate { get; set; }
public uint FrameDelay { get; set; }

/// <summary>
/// Gets or sets the frames count of **one** "icon" chunk.
Expand Down Expand Up @@ -49,14 +49,14 @@ public AniFrameMetadata()
public static AniFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectingFrameMetadata metadata) =>
new()
{
Rate = (uint)metadata.Duration.TotalSeconds * 60
FrameDelay = (uint)metadata.Duration.TotalSeconds * 60
};

/// <inheritdoc/>
IDeepCloneable IDeepCloneable.DeepClone() => new AniFrameMetadata { Rate = this.Rate };
IDeepCloneable IDeepCloneable.DeepClone() => new AniFrameMetadata { FrameDelay = this.FrameDelay };

/// <inheritdoc/>
public FormatConnectingFrameMetadata ToFormatConnectingFrameMetadata() => new FormatConnectingFrameMetadata() { Duration = TimeSpan.FromSeconds(this.Rate / 60d) };
public FormatConnectingFrameMetadata ToFormatConnectingFrameMetadata() => new FormatConnectingFrameMetadata() { Duration = TimeSpan.FromSeconds(this.FrameDelay / 60d) };

/// <inheritdoc/>
public void AfterFrameApply<TPixel>(ImageFrame<TPixel> source, ImageFrame<TPixel> destination)
Expand All @@ -66,5 +66,5 @@ public void AfterFrameApply<TPixel>(ImageFrame<TPixel> source, ImageFrame<TPixel
}

/// <inheritdoc/>
public AniFrameMetadata DeepClone() => new() { Rate = this.Rate };
public AniFrameMetadata DeepClone() => new() { FrameDelay = this.FrameDelay };
}