title: How to Convert byte array to ImageSource for Windows 8.0 store application
body: <p>I am working on Windows 8 store application. I am new at it.</p>
  
  <p>I am receiving an image in the form of byte array (byte []).</p>
  
  <p>I have to convert this back to Image and display it in Image Control.</p>
  
  <p>so far I have button and Image control on Screen. When I click button, I call following function</p>
  
  <pre><code>private async Task LoadImageAsync()
  {
      byte[] code = //call to third party API for byte array
      System.IO.MemoryStream ms = new MemoryStream(code);
      var bitmapImg = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
  
      Windows.Storage.Streams.InMemoryRandomAccessStream imras = new Windows.Storage.Streams.InMemoryRandomAccessStream();
  
      Windows.Storage.Streams.DataWriter write = new Windows.Storage.Streams.DataWriter(imras.GetOutputStreamAt(0));
      write.WriteBytes(code);
      await write.StoreAsync();
      bitmapImg.SetSourceAsync(imras);
      pictureBox1.Source = bitmapImg;
  }
  </code></pre>
  
  <p>This is not working properly. any idea?
  When I debug, I can see the byte array in ms. but it is not getting converted to bitmapImg. </p>