/// <summary> /// Gets .png format image of the .dds texture. /// </summary> /// <returns>.png format image of the .dds texture.</returns> public override unsafe Image GetImage() { var data = this.GetDDSArray(); using (var DataStream = new MemoryStream(data)) using (var ResultStream = new MemoryStream()) using (var importer = new DevIL.ImageImporter()) using (var exporter = new DevIL.ImageExporter()) { using (var InterImage = importer.LoadImageFromStream(DataStream)) { exporter.SaveImageToStream(InterImage, DevIL.ImageType.Png, ResultStream); var result = Image.FromStream(ResultStream); return(result); } } }
public SD.Bitmap LoadImage(DevIL.ImageImporter ImImport, MemoryStream mStream, int width = 128, int height = 128) { try { DevIL.Image IconImg = ImImport.LoadImageFromStream(mStream); IconImg.Bind(); var img = new SD.Bitmap(IconImg.Width, IconImg.Height, SDI.PixelFormat.Format32bppArgb); SD.Rectangle rect = new SD.Rectangle(0, 0, IconImg.Width, IconImg.Height); SDI.BitmapData data = img.LockBits(rect, SDI.ImageLockMode.WriteOnly, SDI.PixelFormat.Format32bppArgb); DevIL.Unmanaged.IL.CopyPixels(0, 0, 0, IconImg.Width, IconImg.Height, 1, DevIL.DataFormat.BGRA, DevIL.DataType.UnsignedByte, data.Scan0); img.UnlockBits(data); return(img); } catch { return(new SD.Bitmap(width, height)); } }
public Bitmap LoadImage(DevIL.ImageImporter ImImport, MemoryStream mStream, int width = 128, int height = 128) { try { Bitmap img2 = null; using (DevIL.Image IconImg = ImImport.LoadImageFromStream(mStream)) { IconImg.Bind(); using (var img = new Bitmap(IconImg.Width, IconImg.Height, PixelFormat.Format32bppArgb)) { Rectangle rect = new Rectangle(0, 0, IconImg.Width, IconImg.Height); BitmapData data = img.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); DevIL.Unmanaged.IL.CopyPixels(0, 0, 0, IconImg.Width, IconImg.Height, 1, DevIL.DataFormat.BGRA, DevIL.DataType.UnsignedByte, data.Scan0); img.UnlockBits(data); img2 = (Bitmap)img.Clone(); } } return(img2); } catch { return(new Bitmap(width, height)); } }