user70192
user70192

Reputation: 14204

Load byte[] into a System.Windows.Controls.Image at Runtime

I have a byte[] that represents a .png file. I am downloading this .png via a WebClient. When the WebClient has downloaded the .png I reference via a URL, I get a byte[]. My question is, how do I load a byte[] into a System.Windows.Controls.Image element in WPF? Thank you.

Note: This is complementary to the question I asked here: Load a byte[] into an Image at Runtime. I was not specific enough in my original question, but the answers were still relevant.

Upvotes: 2

Views: 4916

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1500365

Use a PngBitmapDecoder. The docs show example usage.

Upvotes: 1

Quintin Robinson
Quintin Robinson

Reputation: 82335

In addition to the answers you got on the other question.. which should work fine, you should also be able to create a BitmapImage object and set the UriSource to the web URI instead of using a webclient and then set the Image.Source to the BitmapImage.. See This

Upvotes: 0

Related Questions