using System.Drawing; using System.IO; using OpenTK.Graphics.OpenGL; namespace RecrownedGTK.Graphics { public class TextureData { int handle; byte[] textureData; public byte[] ColorData { get { return textureData; } } public TextureData(string path) { LoadFromPNG(path); } public TextureData() { //TODO: Finish this class. } public TextureData(byte[] textureData, int width, int height, int mipmap = 0) { this.textureData = textureData; GL.TexImage2D(TextureTarget.Texture2D, mipmap, PixelInternalFormat.Rgba, width, height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, textureData); } 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[])); } } } } }