AnimationEditor - Fix null reference exception when loading treeview

This commit is contained in:
miku-666
2024-04-29 20:56:28 +02:00
parent 8f475070e3
commit 76c8a856fe
2 changed files with 6 additions and 0 deletions

View File

@@ -15,6 +15,10 @@ namespace PckStudio.Extensions
{
internal static Image CreateAnimationImage(this Animation animation)
{
if (animation.FrameCount == 0)
{
return null;
}
var ms = new System.IO.MemoryStream();
var generateor = new AnimatedGifCreator(ms, Animation.GameTickInMilliseconds, 0);
foreach (var frame in animation.GetInterpolatedFrames())

View File

@@ -94,6 +94,8 @@ namespace PckStudio.Forms.Editor
TextureIcons.Images.AddRange(_animation.GetTextures().ToArray());
UpdateTreeView();
animationPictureBox.Image ??= _animation.CreateAnimationImage();
if (_animation.FrameCount > 0)
{
animationPictureBox.Image.SelectActiveFrame(FrameDimension.Page, 0);