首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自文件的BitmapSource

来自文件的BitmapSource
EN

Stack Overflow用户
提问于 2010-08-06 03:16:07
回答 3查看 38.1K关注 0票数 31

如何从图像文件加载BitmapSource

EN

回答 3

Stack Overflow用户

发布于 2012-11-19 11:50:06

这对我来说很有效:

代码语言:javascript
复制
BitmapSource bSource = new BitmapImage(new Uri("c:\\image.bmp"));
BitmapImage bImage = new BitmapImage(new Uri("c:\\image.bmp"));
票数 53
EN

Stack Overflow用户

发布于 2010-08-06 03:40:43

您可以将图像的字节从磁盘读取到字节数组中,然后创建BitmapImage对象。

代码语言:javascript
复制
var stream = new MemoryStream(imageBytes);
var img = new System.Windows.Media.Imaging.BitmapImage();

img.BeginInit();
img.StreamSource = stream;
img.EndInit();

return img;
票数 8
EN

Stack Overflow用户

发布于 2012-07-20 05:17:31

代码如下:

代码语言:javascript
复制
FileStream fileStream = 
    new FileStream(fileName, FileMode.Open, FileAccess.Read);

var img = new System.Windows.Media.Imaging.BitmapImage();
img.BeginInit();
img.StreamSource = fileStream;
img.EndInit();
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3418323

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档