title: Convert A Byte[] Array to Image in Xamarin Forms
body: <p>Before asking this question I googled a lot but couldn't find a solution that suits mine.</p>
  
  <p>In <code>Xamarin.Forms</code> I have a <code>byte[]</code> array and I want to Convert that <code>byte[]</code> array to an <code>Image</code>. How can I achieve that, this is what I tried:</p>
  
  <p><strong>In Front End(XAML):</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;StackLayout BackgroundColor="Olive" x:Name="imagePanel"&gt;
      &lt;Image x:Name="PdfImage" Aspect="AspectFill" IsVisible="true"/&gt;
  &lt;/StackLayout&gt;   
  </code></pre>
  
  
  
  <p><strong>In Code Behind(C#):</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>byte[] imageAsBytes = Constant.jsonPDF;
  
  var stream1 = new MemoryStream(imageAsBytes);
  PdfImage.Source = ImageSource.FromStream(() =&gt; new MemoryStream(imageAsBytes));
  
  imagePanel.Children.Add(PdfImage);
  </code></pre>
  
  
  
  <p>But My problem is image is not displaying.</p>
  
  <p>Can anybody tell me what I'm doing wrong. Any help would be greatly appreciated.</p>