Browse Source

Fixed resize canvas protected memory error

flabbet 5 years ago
parent
commit
c4d1a65cc7
1 changed files with 2 additions and 1 deletions
  1. 2 1
      PixiEditor/Models/DataHolders/Document.cs

+ 2 - 1
PixiEditor/Models/DataHolders/Document.cs

@@ -194,6 +194,7 @@ namespace PixiEditor.Models.DataHolders
         {
             int sizeOfArgb = 4;
             int iteratorHeight = oldHeight > newHeight ? newHeight : oldHeight;
+            int count = oldWidth > newWidth ? newWidth : oldWidth;
             for (int i = 0; i < Layers.Count; i++)
             {
                 using (var srcContext = Layers[i].LayerBitmap.GetBitmapContext(ReadWriteMode.ReadOnly))
@@ -205,7 +206,7 @@ namespace PixiEditor.Models.DataHolders
                         {
                             var srcOff = ((offsetYSrc + line) * oldWidth + offsetXSrc) * sizeOfArgb;
                             var dstOff = ((offsetY + line) * newWidth + offsetX) * sizeOfArgb;
-                            BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, oldWidth * sizeOfArgb);
+                            BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, count * sizeOfArgb);
                         }
                         Layers[i].LayerBitmap = result;
                         Layers[i].Width = newWidth;