Files
Voile/DaggerFramework/Source/Resources/Loaders/Texture2dLoader.cs
2023-06-18 22:16:28 +02:00

37 lines
917 B
C#
Executable File

using DaggerFramework.Resources;
using StbImageSharp;
namespace DaggerFramework
{
public class Texture2dLoader : IResourceLoader
{
public IEnumerable<string> SupportedExtensions => new string[]
{
".png",
".jpg",
".jpeg"
};
public Type ResourceType => typeof(Texture2d);
public Resource Load(string path)
{
ImageResult image;
using (var stream = File.OpenRead(path))
{
image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
}
Texture2d result = new Texture2d(path, image.Data);
result.Width = image.Width;
result.Height = image.Height;
return result;
}
Resource IResourceLoader.Load(string path)
{
throw new NotImplementedException();
}
}
}