如何阅读在WPF一个base64形象? [英] How do i read a base64 image in WPF?

查看:218
本文介绍了如何阅读在WPF一个base64形象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道该怎么做,在的WinForms

 字节[] binaryData = Convert.FromBase64String(bgImage64);
图像= Image.FromStream(新的MemoryStream(binaryData));
 

但我如何做同样的事情在WPF?

解决方案

 字节[] binaryData = Convert.FromBase64String(bgImage64);

BitmapImage的BI =新的BitmapImage;
bi.BeginInit();
bi.StreamSource =新的MemoryStream(binaryData);
bi.EndInit();

图片IMG =新的图像();
img.Source =双向;
 

I know how to do it in WinForms

byte[] binaryData = Convert.FromBase64String(bgImage64);
image = Image.FromStream(new MemoryStream(binaryData));

but how do i do the same thing in WPF?

解决方案

byte[] binaryData = Convert.FromBase64String(bgImage64);

BitmapImage bi = new BitmapImage;
bi.BeginInit();
bi.StreamSource = new MemoryStream(binaryData);
bi.EndInit();

Image img = new Image();
img.Source = bi;

这篇关于如何阅读在WPF一个base64形象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆