2019-12-21 07:06:56 +00:00
|
|
|
using System.Drawing;
|
2019-12-12 19:44:51 +00:00
|
|
|
using System.IO;
|
2019-12-21 07:06:56 +00:00
|
|
|
|
2019-12-28 23:06:04 +00:00
|
|
|
namespace RecrownedAthenaeum.Graphics {
|
2019-12-21 07:06:56 +00:00
|
|
|
public class Texture : IRectangleDrawable {
|
2019-12-28 23:06:04 +00:00
|
|
|
//TODO Complete a basic texture capable of being rendered by a batch.
|
2019-12-12 19:44:51 +00:00
|
|
|
byte[] textureData;
|
2019-12-21 07:06:56 +00:00
|
|
|
public byte[] ColorData {
|
|
|
|
get {
|
|
|
|
return textureData;
|
|
|
|
}
|
|
|
|
}
|
2019-12-12 19:44:51 +00:00
|
|
|
public Texture() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public Texture(byte[] textureData) {
|
|
|
|
this.textureData = textureData;
|
|
|
|
}
|
|
|
|
|
2019-12-21 07:06:56 +00:00
|
|
|
public Texture(string path) {
|
|
|
|
LoadFromPNG(path);
|
|
|
|
}
|
|
|
|
|
2019-12-12 19:44:51 +00:00
|
|
|
public void LoadFromPNG(string path) {
|
|
|
|
using (FileStream file = new FileStream(path, FileMode.Open)) {
|
2019-12-21 07:06:56 +00:00
|
|
|
using (Bitmap bitmap = new Bitmap(file)) {
|
|
|
|
ImageConverter converter = new ImageConverter();
|
|
|
|
textureData = (byte[]) converter.ConvertTo(bitmap, typeof(byte[]));
|
|
|
|
}
|
2019-12-12 19:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|