mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 16:16:30 +00:00
25 lines
786 B
C#
25 lines
786 B
C#
using System.Drawing;
|
|
using AnimatedGif;
|
|
|
|
namespace PckStudio.Core.Extensions
|
|
{
|
|
public static class AnimationExtensions
|
|
{
|
|
public static Image CreateAnimationImage(this Animation animation)
|
|
{
|
|
if (animation.FrameCount == 0)
|
|
{
|
|
return null;
|
|
}
|
|
var ms = new System.IO.MemoryStream();
|
|
var generateor = new AnimatedGifCreator(ms, GameConstants.GameTickInMilliseconds, 0);
|
|
foreach (Animation.Frame frame in animation.GetInterpolatedFrames())
|
|
{
|
|
generateor.AddFrame(frame.Texture, frame.Ticks * GameConstants.GameTickInMilliseconds, GifQuality.Bit8);
|
|
}
|
|
ms.Position = 0;
|
|
return Image.FromStream(ms);
|
|
}
|
|
}
|
|
}
|