title: Alternative to BitmapImage to load a PNG
body: <p>On a WPF project, I need to set a ImageSource property from a local Resource.
  I am trying to use the following code:</p>
  
  <pre><code>   var bmp = new BitmapImage();
     bmp.BeginInit();
     bmp.UriSource = new Uri("pack://application:,,,/Resources/Identicons/no_user.jpg", UriKind.Absolute);
     bmp.EndInit();
     Avatar = bmp;
  </code></pre>
  
  <p>Where Avatar is defined before as:</p>
  
  <pre><code>private ImageSource myAvatar;
  </code></pre>
  
  <p>The problem is that BitmapImage does not support MetaData information, that the source image have (it was created with Paint.net) so it throws a error. The error is the following:</p>
  
  <blockquote>
    <p>Metadata = 'bmp.Metadata' threw an exception of type
    'System.NotSupportedException'</p>
  </blockquote>
  
  <p>So I believe that I need alternatives to BitmapImage to properly load the desired image.</p>
  
  <p>As a end note, using the same image inside xaml, directly in a "source" property it works fine.
  Thank you</p>