public static Texture FromFile(string path) { // Set up the texture fire Texture tex = new Texture(); // Just trust the file extension for now string ext = Path.GetExtension(path); // DDS files are a special case, as there's no built in support for loading them // Because of this, we'll need to parse the file manually if (ext.Equals(".dds")) { DDSHelper dds = DDSHelper.FromFile(path); tex.Width = (ushort)dds.ddsFile.Header.Width; tex.Height = (ushort)dds.ddsFile.Header.Height; tex.Depth = (ushort)dds.ddsFile.Header.Width; // FIX THIS WHEN NOT LAZY tex.Flags = (ushort)Descriptor.DXT1; tex.MipMapCount = (byte)dds.ddsFile.Header.MipMapCount; // Not finished... } // Otherwise just let GDI+ handle it and the conversion // We'll ultimately just pull RGBA format out of it else { // Read the file and convert it to RGBX using (Bitmap temp = new Bitmap(path)) { tex.originalBitmap = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppRgb); tex.combinedBitmap = tex.originalBitmap; //tex.bitmaps.Add(conv); } // Just use the size of the main surface tex.Width = (ushort)tex.originalBitmap.Width; tex.Height = (ushort)tex.originalBitmap.Height; tex.DataSize = (uint)(tex.Width * tex.Height) * 4; } return(tex); }