WPF VB.NET图像不会出现在内存流中 [英] WPF VB.NET Image not appear from memorystream

查看:65
本文介绍了WPF VB.NET图像不会出现在内存流中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一张图片要在我的页面中查看。但我想知道为什么这个图像不是视图。我的其他程序使用相同的代码,图像可以查看。但就这一点来说,它并没有出现。如果我手动选择源,它有图像视图。通过代码,它不是。请看一下我的代码。



Hi all,

I have an image to be view in my page. But I wonder why this image is not view. My others program use the same code and image can be view. But on this one, it's not appear. If I manually select the source, it has image view. By code, its not. Please take a look at my code.

If Not IsNothing(.event_logo) Then
    cv_logo.Visibility = Windows.Visibility.Visible
    Dim mstream As System.IO.MemoryStream
    Dim photo2 As New BitmapImage()
    img_eventlogo = New Image
    'If logo bytes is not null, fill into image to be view
    mstream = New System.IO.MemoryStream(udt_meeting.event_logo)
    photo2.BeginInit()
    photo2.StreamSource = mstream
    photo2.CacheOption = BitmapCacheOption.OnLoad
    photo2.EndInit()
    img_eventlogo.Source = photo2
    img_eventlogo.Stretch = Stretch.Fill
    mstream = Nothing
End If





***我搜索了用于将字节流式传输到图像的其他代码的Internet。但它不起作用..



请help.TQ



*** I have search for the internet for other code to stream byte to image. But it's not working..

Please assist.TQ

推荐答案

我找到了解决方案,< br $>


I have found the solutions,

Using stream = New MemoryStream(.event_logo)
    Dim bitmap = New BitmapImage()
    bitmap.BeginInit()
    bitmap.StreamSource = stream
    bitmap.CacheOption = BitmapCacheOption.OnLoad
    bitmap.EndInit()
    bitmap.Freeze()
    img_righteventlogo.Source = bitmap
End Using





我不知道我的邮政编码和答案代码有什么不同。但答案有效



I don't know what is the different between my post code and my answer code. But the answer works


这篇关于WPF VB.NET图像不会出现在内存流中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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