public static Bitmap ImportBitmap(string path) { try { return(new Bitmap(path)); } catch (Exception) { var ext = Path.GetExtension(path).ToLowerInvariant(); switch (ext) { case ".dds": return(DDSCodec.DecompressImage(path)); default: return(new Bitmap(32, 32)); } } }
private static Bitmap DecodeDDS(byte[] data) { try { // Prefer DDSCodec -- handles alpha properly but doesn't handle non pow 2 textures & DX10+ formats return(DDSCodec.DecompressImage(data)); } catch (Exception) { } try { // Image engine SUCKS at alpha handling, but its better than nothing return(DecodeDDSWithImageEngine(data)); } catch (Exception) { } // RIP Trace.WriteLine("Failed to decode DDS texture"); return(new Bitmap(32, 32, PixelFormat.Format32bppArgb)); }
protected override Bitmap GetBitmapCore(DDSStream obj) { return(DDSCodec.DecompressImage(obj)); }
public Bitmap GetBitmap() { return(mBitmap ?? (mBitmap = DDSCodec.DecompressImage(Data))); }