博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
BitmapImage 读取内存流和显示图片
阅读量:4483 次
发布时间:2019-06-08

本文共 442 字,大约阅读时间需要 1 分钟。

FileStream filestream = File.OpenRead(@"C:\Users\Administrator\Desktop\queryHeaderImg.png");

BitmapImage image = new BitmapImage();
MemoryStream stream = new MemoryStream();

filestream.CopyTo(stream);

 

 

我开始将stream 赋值给BitmapImage 中的StreamSource 但是图片一直报错,

提示StreamSource 为null

 

查找资料 一定要要先初始货才能给StreamSource赋值。

 

bitmapImage.BeginInit();

bitmapImage.StreamSource = stream;
bitmapImage.EndInit();

转载于:https://www.cnblogs.com/qq247039968/p/4215332.html

你可能感兴趣的文章
Asterisk 代码架构概述
查看>>
中兴电信光纤猫F450获取管理员密码方法
查看>>
申请TexturePacker 或 PhysicsEditor free licenses
查看>>
kafka启动报错&问题解决
查看>>
nginx反向代理下没有获取到正确的clientIP问题发散
查看>>
python周报第一周
查看>>
IBM MQ 创建以及常见问题集锦
查看>>
Office文件的奥秘——.NET平台下不借助Office实现Word、Powerpoint等文件的解析(1)
查看>>
SQL Server 服务器磁盘测试之SQLIO篇(一)
查看>>
JQ插件写法 扩展JQ方法
查看>>
[LeetCode&Python] Problem 543. Diameter of Binary Tree
查看>>
226 Invert Binary Tree 翻转二叉树
查看>>
《Pro ASP.NET MVC 3 Framework》学习笔记之十六【示例项目SportsStore】
查看>>
IntelliJ IDEA的安装及永久破解
查看>>
C#多线程编程
查看>>
替换空格
查看>>
IntelliJ IDEA2018.1、2017.3激活
查看>>
Orchard后台控制面板的介绍
查看>>
大二下第一周----开学测试
查看>>
javaweb-servlet生成简单的验证码
查看>>