2

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.

Community
  • 1
  • 1
user70192
  • 13,786
  • 51
  • 160
  • 240

2 Answers2

1

Use a PngBitmapDecoder. The docs show example usage.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
0

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

Quintin Robinson
  • 81,193
  • 14
  • 123
  • 132