Explorar o código

More straight forward

CPKreuz %!s(int64=3) %!d(string=hai) anos
pai
achega
b8aa6b88f4
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  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");
                 }
             }