想在wpf中显示图像 [英] want to show image in wpf

查看:47
本文介绍了想在wpf中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在wpf图片框中显示图片。该图像在数据库中采用字节格式。我将如何显示该图像。请帮帮我。

i want to show image in wpf image box. that image is in byte format at database. how will i show that image. please help me out.

推荐答案

最后我找到了答案

finally i found the answer
byte[] b;
                //b=memStream.GetBuffer();
        b = System.IO.File.ReadAllBytes(openfile.FileName);
        MemoryStream byteStream = new MemoryStream(b);
        BitmapImage image = new BitmapImage();
        image.BeginInit();
        image.StreamSource = byteStream;
        image.EndInit();

        image1.Source = image;


确保提供图像的完整路径。

Make sure you give the full path to the image.
<image name="image4" stretch="None" source="C:\Users\smevis\Desktop\WpfApplication1\mn.png" isenabled="True" stretchdirection="Both" />


这篇关于想在wpf中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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