我需要将一张图片转换为位图。
最初,一个gif作为字节读入,然后被转换成了一张图片。
但是当我尝试将图片转换为位图时,显示在picturebox中的图像背景变为黑色,而之前是白色的。
这是代码:
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;
有人能解释一下为什么背景会变黑并告诉我如何阻止它这样做吗?
谢谢