Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

VB
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


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

Please assist.TQ
Posted

1 solution

I have found the solutions,

VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900