recrownedgtk/RecrownedAthenaeum/Types/Texture.cs

35 lines
934 B
C#
Raw Normal View History

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
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[]));
}
}
}
}
}