2024-08-18 09:27:44 +00:00
|
|
|
using Godot;
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
|
|
|
|
namespace KeepersCompound.TMV;
|
|
|
|
|
|
|
|
public partial class TextureLoader
|
|
|
|
{
|
|
|
|
// TODO: Replace this with my own implementation lol
|
|
|
|
// References:
|
|
|
|
// - https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
|
|
|
private static ImageTexture LoadGif(string path)
|
|
|
|
{
|
|
|
|
using var gifImage = SixLabors.ImageSharp.Image.Load<Rgba32>(path);
|
|
|
|
|
|
|
|
var width = gifImage.Width;
|
|
|
|
var height = gifImage.Height;
|
2024-08-30 17:22:40 +00:00
|
|
|
var bytes = new byte[width * height * 4];
|
|
|
|
gifImage.CopyPixelDataTo(bytes);
|
|
|
|
var image = Image.CreateFromData(width, height, false, Image.Format.Rgba8, bytes);
|
2024-08-18 09:27:44 +00:00
|
|
|
return ImageTexture.CreateFromImage(image);
|
|
|
|
}
|
|
|
|
}
|