recrownedgtk/RecrownedAthenaeum/Types/Texture.cs

33 lines
872 B
C#

using System.Drawing;
using System.IO;
namespace RecrownedAthenaeum.Types {
public class Texture : IRectangleDrawable {
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[]));
}
}
}
}
}