title: WPF Byte array to BitmapImage
body: <p>I read all first page results of "Byte array to BitmapImage" and I fount
  <a href="https://stackoverflow.com/questions/17762747/byte-array-to-bitmapimage-wp">Byte array to BitmapImage WP</a>
  <a href="https://stackoverflow.com/questions/3335819/byte-to-bitmapimage-in-silverlight">byte[] to BitmapImage in silverlight</a>
  the problem is that I code dosen't work for me and I get this error:</p>
  
  <blockquote>
    <p>'System.Windows.Media.Imaging.BitmapImage' does not contain a
    definition for 'SetSource' and no extension method 'SetSource'
    accepting a first argument of type
    'System.Windows.Media.Imaging.BitmapImage' could be found (are you
    missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>My main code is:</p>
  
  <pre><code>int stride = CoverPhotoBitmap.PixelWidth * 4;
  int size = CoverPhotoBitmap.PixelHeight * stride;
  byte[] CoverPhotoPixels = new byte[size];
  CoverPhotoBitmap.CopyPixels(CoverPhotoPixels, stride, 0);
  
  byte[] HiddenPhotoPixels = new byte[size];
  HiddenPhotoBitmap.CopyPixels(HiddenPhotoPixels, stride, 0);
  ResultPhotoBitmap = ByteArraytoBitmap(HiddenPhotoPixels);
  </code></pre>
  
  <p>and my method is:</p>
  
  <pre><code>public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
  {
      MemoryStream stream = new MemoryStream(byteArray);
      BitmapImage bitmapImage = new BitmapImage();
      bitmapImage.SetSource(stream);
      return bitmapImage;
  }
  </code></pre>