CPKreuz преди 3 години
родител
ревизия
b8aa6b88f4
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3 3
      PixiEditor/Models/DataHolders/Surface.cs

+ 3 - 3
PixiEditor/Models/DataHolders/Surface.cs

@@ -125,12 +125,12 @@ namespace PixiEditor.Models.DataHolders
         {
             var imageInfo = new SKImageInfo(Width, Height, colorType, alphaType, SKColorSpace.CreateSrgb());
 
-            byte[] buffer = new byte[Width * Height * 4];
+            byte[] buffer = new byte[Width * Height * imageInfo.BytesPerPixel];
             fixed (void* pointer = buffer)
             {
-                if (!SkiaSurface.Snapshot().ReadPixels(imageInfo, new IntPtr(pointer)))
+                if (!SkiaSurface.ReadPixels(imageInfo, new IntPtr(pointer), imageInfo.RowBytes, 0, 0))
                 {
-                    throw new InvalidOperationException("Could not read image into buffer");
+                    throw new InvalidOperationException("Could not read surface into buffer");
                 }
             }