Browse Source

CloneFromLatest

Krzysztof Krysiński 1 week ago
parent
commit
295c44aa3b

+ 25 - 1
src/ChunkyImageLib/ChunkyImage.cs

@@ -393,6 +393,30 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
         }
         }
     }
     }
 
 
+    public ChunkyImage CloneFromLatest()
+    {
+        lock (lockObject)
+        {
+            ThrowIfDisposed();
+            ChunkyImage output = new(LatestSize, ProcessingColorSpace);
+            var chunks = FindAllChunks();
+            foreach (var chunk in chunks)
+            {
+                var image = GetLatestChunk(chunk, ChunkResolution.Full);
+                if (image is null)
+                {
+                    image = GetCommittedChunk(chunk, ChunkResolution.Full);
+                    if (image is null)
+                        continue;
+                }
+                output.EnqueueDrawTexture(chunk * FullChunkSize, image.Surface);
+            }
+
+            output.CommitChanges();
+            return output;
+        }
+    }
+
     /// <exception cref="ObjectDisposedException">This image is disposed</exception>
     /// <exception cref="ObjectDisposedException">This image is disposed</exception>
     public Color GetCommittedPixel(VecI posOnImage)
     public Color GetCommittedPixel(VecI posOnImage)
     {
     {
@@ -1736,7 +1760,7 @@ public class ChunkyImage : IReadOnlyChunkyImage, IDisposable, ICloneable, ICache
         lock (lockObject)
         lock (lockObject)
         {
         {
             ThrowIfDisposed();
             ThrowIfDisposed();
-            ChunkyImage clone = CloneFromCommitted();
+            ChunkyImage clone = CloneFromLatest();
             return clone;
             return clone;
         }
         }
     }
     }

+ 0 - 1
src/PixiEditor/ViewModels/Document/DocumentViewModel.cs

@@ -953,7 +953,6 @@ internal partial class DocumentViewModel : PixiObservableObject, IDocument
         Surface output = Surface.ForDisplay(finalBounds.Size);
         Surface output = Surface.ForDisplay(finalBounds.Size);
 
 
         VectorPath clipPath = new VectorPath(SelectionPathBindable) { FillType = PathFillType.EvenOdd };
         VectorPath clipPath = new VectorPath(SelectionPathBindable) { FillType = PathFillType.EvenOdd };
-        //clipPath.Transform(Matrix3X3.CreateTranslation(-bounds.X, -bounds.Y));
         output.DrawingSurface.Canvas.Save();
         output.DrawingSurface.Canvas.Save();
         output.DrawingSurface.Canvas.Translate(-finalBounds.X, -finalBounds.Y);
         output.DrawingSurface.Canvas.Translate(-finalBounds.X, -finalBounds.Y);
         if (!clipPath.IsEmpty)
         if (!clipPath.IsEmpty)