Пример #1
0
        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));
                }
            }
        }
Пример #2
0
        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));
        }
Пример #3
0
 protected override Bitmap GetBitmapCore(DDSStream obj)
 {
     return(DDSCodec.DecompressImage(obj));
 }
Пример #4
0
 public Bitmap GetBitmap()
 {
     return(mBitmap ?? (mBitmap = DDSCodec.DecompressImage(Data)));
 }