如何创建一个System.Windows.Media.ImageSource从字节数组? [英] How Do I Create a System.Windows.Media.ImageSource From a Byte Array?

查看:100
本文介绍了如何创建一个System.Windows.Media.ImageSource从字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何创建一个从字节数组System.Windows.Media.ImageSource?

我有一个字节数组,包含TIFF图像文件的准确及完整的文件内容。我需要在屏幕上显示这一点,我不知道在哪里甚至开始。

据推测,这是可以做到(根据我的老板,我们的开发团队已经做了过去,但没有人记得如何)。

有没有人在这里做过这样的事情之前?

解决方案

 的BitmapImage BI =新的BitmapImage();
bi.BeginInit();
bi.StreamSource =新的MemoryStream(字节阵列);
bi.EndInit();
 

另请参见<一href="http://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap">http://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap和<一href="http://stackoverflow.com/questions/1118496/using-image-control-in-wpf-to-display-system-drawing-bitmap">http://stackoverflow.com/questions/1118496/using-image-control-in-wpf-to-display-system-drawing-bitmap

How do I create a System.Windows.Media.ImageSource from a byte array?

I have a byte array, containing the exact and complete file contents of a TIFF image file. I need to display this on the screen, and I have no idea where to even start.

Supposedly, it can be done (according to my boss, our dev team has done it in the past, but nobody remembers how).

Has anyone here ever done something like this before?

解决方案

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

Also see http://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap and http://stackoverflow.com/questions/1118496/using-image-control-in-wpf-to-display-system-drawing-bitmap

这篇关于如何创建一个System.Windows.Media.ImageSource从字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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