Faster GIF loading

This commit is contained in:
Jarrod Doyle 2024-08-30 18:22:40 +01:00
parent eca63077b8
commit 38a360793a
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 3 additions and 10 deletions

View File

@ -14,16 +14,9 @@ public partial class TextureLoader
var width = gifImage.Width;
var height = gifImage.Height;
var image = Image.CreateEmpty(width, height, false, Image.Format.Rgba8);
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var pixel = gifImage[x, y].ToVector4();
image.SetPixel(x, y, new Color(pixel.X, pixel.Y, pixel.Z, pixel.W));
}
}
var bytes = new byte[width * height * 4];
gifImage.CopyPixelDataTo(bytes);
var image = Image.CreateFromData(width, height, false, Image.Format.Rgba8, bytes);
return ImageTexture.CreateFromImage(image);
}
}