Skip to content

Add ANI decoder support #2899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
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
fix AniMetadata
  • Loading branch information
Poker-sang committed Apr 7, 2025
commit ed0edfe20a62f3f3d15be52ad508d9915cf15e4b
10 changes: 1 addition & 9 deletions src/ImageSharp/Formats/Ani/AniFrameMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ public static AniFrameMetadata FromFormatConnectingFrameMetadata(FormatConnectin
};

/// <inheritdoc/>
IDeepCloneable IDeepCloneable.DeepClone() => new AniFrameMetadata
{
FrameDelay = this.FrameDelay,
EncodingHeight = this.EncodingHeight,
EncodingWidth = this.EncodingWidth,
FrameCount = this.FrameCount

// TODO SubImageMetadata
};
IDeepCloneable IDeepCloneable.DeepClone() => this.DeepClone();

/// <inheritdoc/>
public FormatConnectingFrameMetadata ToFormatConnectingFrameMetadata() => new FormatConnectingFrameMetadata() { Duration = TimeSpan.FromSeconds(this.FrameDelay / 60d) };
Expand Down
41 changes: 35 additions & 6 deletions src/ImageSharp/Formats/Ani/AniMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,33 @@ public AniMetadata()
/// <summary>
/// Gets or sets the width of frames in the animation.
/// </summary>
/// <remarks>
/// Remains zero when <see cref="Flags"/> has flag <see cref="AniHeaderFlags.IsIcon"/>
/// </remarks>
public uint Width { get; set; }

/// <summary>
/// Gets or sets the height of frames in the animation.
/// </summary>
/// <remarks>
/// Remains zero when <see cref="Flags"/> has flag <see cref="AniHeaderFlags.IsIcon"/>
/// </remarks>
public uint Height { get; set; }

/// <summary>
/// Gets or sets the number of bits per pixel.
/// </summary>
/// <remarks>
/// Remains zero when <see cref="Flags"/> has flag <see cref="AniHeaderFlags.IsIcon"/>
/// </remarks>
public uint BitCount { get; set; }

/// <summary>
/// Gets or sets the number of frames in the animation.
/// </summary>
/// <remarks>
/// Remains zero when <see cref="Flags"/> has flag <see cref="AniHeaderFlags.IsIcon"/>
/// </remarks>
public uint Planes { get; set; }

/// <summary>
Expand Down Expand Up @@ -64,21 +76,38 @@ public AniMetadata()
public IList<ImageFrameMetadata> IconFrames { get; set; } = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is wise. We've ended up with a type that can hold and store any image format metadata.


/// <inheritdoc/>
public static AniMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata) => throw new NotImplementedException();
public static AniMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata)
=> throw new NotImplementedException();

/// <inheritdoc/>
public void AfterImageApply<TPixel>(Image<TPixel> destination)
where TPixel : unmanaged, IPixel<TPixel> => throw new NotImplementedException();
where TPixel : unmanaged, IPixel<TPixel>
{
}

/// <inheritdoc/>
public IDeepCloneable DeepClone() => throw new NotImplementedException();
IDeepCloneable IDeepCloneable.DeepClone() => this.DeepClone();

/// <inheritdoc/>
public PixelTypeInfo GetPixelTypeInfo() => throw new NotImplementedException();
public PixelTypeInfo GetPixelTypeInfo()
=> throw new NotImplementedException();

/// <inheritdoc/>
public FormatConnectingMetadata ToFormatConnectingMetadata() => throw new NotImplementedException();
public FormatConnectingMetadata ToFormatConnectingMetadata()
=> throw new NotImplementedException();

/// <inheritdoc/>
AniMetadata IDeepCloneable<AniMetadata>.DeepClone() => throw new NotImplementedException();
public AniMetadata DeepClone() => new()
{
Width = this.Width,
Height = this.Height,
BitCount = this.BitCount,
Planes = this.Planes,
DisplayRate = this.DisplayRate,
Flags = this.Flags,
Name = this.Name,
Artist = this.Artist

// TODO IconFrames
};
}
Loading