Faster GIF loading
This commit is contained in:
parent
eca63077b8
commit
38a360793a
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue