From 870d18c643e51da79b14a8797a528e1b2be7132a Mon Sep 17 00:00:00 2001 From: Sarah Duck Date: Mon, 16 Jun 2025 22:50:26 -0700 Subject: Fixed how compressed data gets reused --- Bitmap.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Bitmap.cs') diff --git a/Bitmap.cs b/Bitmap.cs index 6922fae..1627adb 100644 --- a/Bitmap.cs +++ b/Bitmap.cs @@ -69,7 +69,7 @@ class Bitmap : IDisposable public static Bitmap Deserialize(ReadOnlySpan span, int MaxW = MaxWidth, int MaxH = MaxHeight, Image? fallbackImage = null) { - int width = BinaryPrimitives.ReadInt16LittleEndian(span[..2]); + int width = BinaryPrimitives.ReadInt16LittleEndian(span); int height = BinaryPrimitives.ReadInt16LittleEndian(span.Slice(2, 2)); PixelFormat format = (PixelFormat)span[4]; int mipmaps = span[5]; @@ -81,10 +81,11 @@ class Bitmap : IDisposable Image img = Raylib.GenImageChecked(Math.Clamp(width, 8, MaxW), Math.Clamp(height, 8, MaxH), 4, 4, Color.Pink, Color.Black); if (Invalid) return new Bitmap(img); - byte[] compressed = span[6..].ToArray(); + byte[] compressed = span.ToArray(); byte[] data = new byte[RaylibExt.TextureLength(width, height, format, mipmaps)]; { using MemoryStream input = new(compressed); + input.Position += 6; using DeflateStream decompressor = new(input, CompressionMode.Decompress); decompressor.ReadExactly(data); } -- cgit