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,048
  • 47
  • 156
  • 233

2 Answers2

1

Use a PngBitmapDecoder. The docs show example usage.

Jon Skeet
  • 1,335,956
  • 823
  • 8,931
  • 9,049
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
  • 78,970
  • 14
  • 121
  • 132