2019-12-21 07:06:56 +00:00
|
|
|
using System.Drawing;
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
using System.Drawing.Imaging;
|
2019-12-12 19:44:51 +00:00
|
|
|
using System.IO;
|
2019-12-21 07:06:56 +00:00
|
|
|
|
2019-12-12 19:44:51 +00:00
|
|
|
namespace RecrownedAthenaeum.Types {
|
2019-12-21 07:06:56 +00:00
|
|
|
public class Texture : IRectangleDrawable {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|