Browse Source

More straight forward

CPKreuz 3 years ago
parent
commit
b8aa6b88f4
1 changed files with 3 additions and 3 deletions
  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");
                 }
             }