如何从图像文件加载BitmapSource?
发布于 2012-11-19 11:50:06
这对我来说很有效:
BitmapSource bSource = new BitmapImage(new Uri("c:\\image.bmp"));
BitmapImage bImage = new BitmapImage(new Uri("c:\\image.bmp"));发布于 2010-08-06 03:40:43
您可以将图像的字节从磁盘读取到字节数组中,然后创建BitmapImage对象。
var stream = new MemoryStream(imageBytes);
var img = new System.Windows.Media.Imaging.BitmapImage();
img.BeginInit();
img.StreamSource = stream;
img.EndInit();
return img;发布于 2012-07-20 05:17:31
代码如下:
FileStream fileStream =
new FileStream(fileName, FileMode.Open, FileAccess.Read);
var img = new System.Windows.Media.Imaging.BitmapImage();
img.BeginInit();
img.StreamSource = fileStream;
img.EndInit();https://stackoverflow.com/questions/3418323
复制相似问题