recrownedgtk/RecrownedGTK/Graphics/Texture.cs

34 lines
947 B
C#
Raw Normal View History

2020-02-17 02:44:21 +00:00
using System.Drawing;
using System.IO;
namespace RecrownedGTK.Graphics {
public class Texture : IRectangleDrawable {
//TODO Complete a basic texture capable of being rendered by a batch.
byte[] textureData;
public byte[] ColorData {
get {
return textureData;
}
}
public Texture() {
}
public Texture(byte[] textureData) {
this.textureData = textureData;
}
public Texture(string path) {
LoadFromPNG(path);
}
public void LoadFromPNG(string path) {
using (FileStream file = new FileStream(path, FileMode.Open)) {
using (Bitmap bitmap = new Bitmap(file)) {
ImageConverter converter = new ImageConverter();
textureData = (byte[]) converter.ConvertTo(bitmap, typeof(byte[]));
}
}
}
}
}