【发布时间】:2011-05-03 07:39:53
【问题描述】:
我需要将图像转换为位图。
最初以字节形式读取 gif,然后将其转换为图像。
但是当我尝试将图像转换为位图时,我的图片框中显示的图形在以前是白色的时候有黑色背景。
代码如下:
var image = (System.Drawing.Image)value;
// Winforms Image we want to get the WPF Image from...
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
bitmap.BeginInit();
MemoryStream memoryStream = new MemoryStream();
// Save to a memory stream...
image.Save(memoryStream, ImageFormat.Bmp);
// Rewind the stream...
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
bitmap.StreamSource = memoryStream;
bitmap.EndInit();
return bitmap;
有人可以解释为什么背景变黑以及我如何阻止它这样做。
谢谢
【问题讨论】: