flabbet 1 рік тому
батько
коміт
50e1ecbd95

+ 7 - 0
src/ChunkyImageLib/ChunkyImage.cs

@@ -9,6 +9,7 @@ using PixiEditor.DrawingApi.Core;
 using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.Numerics;
 using PixiEditor.DrawingApi.Core.Surfaces;
+using PixiEditor.DrawingApi.Core.Surfaces.ImageData;
 using PixiEditor.DrawingApi.Core.Surfaces.PaintImpl;
 using PixiEditor.DrawingApi.Core.Surfaces.Vector;
 using PixiEditor.Numerics;
@@ -125,6 +126,12 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
         };
     }
 
+    public ChunkyImage(Surface image) : this(image.Size)
+    {
+        EnqueueDrawImage(VecI.Zero, image);
+        CommitChanges();
+    }
+
     /// <exception cref="ObjectDisposedException">This image is disposed</exception>
     public RectI? FindChunkAlignedMostUpToDateBounds()
     {

+ 11 - 2
src/PixiEditor.AvaloniaUI/Helpers/DocumentViewModelBuilder.cs

@@ -285,8 +285,17 @@ internal class NodeGraphBuilder
             this.WithNodeOfType(typeof(ImageLayerNode))
                 .WithName(name)
                 .WithId(AllNodes.Count + 1)
-                .WithAdditionalData(
-                    new Dictionary<string, object> { { ImageLayerNode.ImageFramesKey, new List<Surface> { image } } }));
+                .WithKeyFrames(
+                [
+                    new KeyFrameData
+                        {
+                            AffectedElement = ImageLayerNode.ImageLayerKey,
+                            Data = new ChunkyImage(image),
+                            Duration = 0,
+                            StartFrame = 0,
+                            IsVisible = true
+                        }
+                ]));
 
         id = AllNodes.Count;
         return this;

+ 0 - 2
src/PixiEditor.AvaloniaUI/ViewModels/Document/DocumentViewModel.Serialization.cs

@@ -5,11 +5,9 @@ using ChunkyImageLib.DataHolders;
 using Microsoft.Extensions.DependencyInjection;
 using PixiEditor.AvaloniaUI.Helpers;
 using PixiEditor.AvaloniaUI.Helpers.Extensions;
-using PixiEditor.AvaloniaUI.Models.IO;
 using PixiEditor.AvaloniaUI.Models.IO.FileEncoders;
 using PixiEditor.AvaloniaUI.Models.Serialization;
 using PixiEditor.AvaloniaUI.Models.Serialization.Factories;
-using PixiEditor.ChangeableDocument.Changeables;
 using PixiEditor.ChangeableDocument.Changeables.Graph.Interfaces;
 using PixiEditor.ChangeableDocument.Changeables.Interfaces;
 using PixiEditor.DrawingApi.Core;

+ 2 - 2
src/PixiEditor.AvaloniaUI/ViewModels/SubViewModels/FileViewModel.cs

@@ -250,7 +250,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
             .WithSize(image.Size)
             .WithGraph(x => x
                 .WithImageLayerNode(
-                    new LocalizedString("PASTED_IMAGE_NAME"),
+                    new LocalizedString("IMAGE"),
                     image, out int id)
                 .WithOutputNode(id, "Output")
             ));
@@ -273,7 +273,7 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
             .WithSize(surface.Size)
             .WithGraph(x => x
                 .WithImageLayerNode(
-                    new LocalizedString("PASTED_IMAGE_NAME"),
+                    new LocalizedString("IMAGE"),
                     surface, out int id)
                 .WithOutputNode(id, "Output")
             ));