title: How to Convert LuminanceSource to Bitmap in Xamarin.Forms?
body: <p>I want to do image processing with portable.aforge on instant frames that I get from the camera with Xamarin.Forms.</p>
  
  <p>I took the example of zixng project.</p>
  
  <p>In the Zxing project, instant frames from the camera are sent to the xamarin.Form core project as LuminanceSource.</p>
  
  <p>LuminanceSource is <a href="https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/LuminanceSource.cs" rel="nofollow noreferrer">https://github.com/micjahn/ZXing.Net/blob/master/Source/lib/LuminanceSource.cs</a></p>
  
  <p>I need to convert this LuminanceSource source to System.Drawing.Bitmap</p>
  
  <p>When i try to convert like the following code the bitmap is being null.</p>
  
  <p>What I'm doing wrong about this and how can I do this properly?</p>
  
  <pre class="lang-cs prettyprint-override"><code>using (var stream = new MemoryStream(luminanceSource.Matrix))
  {
      stream.Seek(0, SeekOrigin.Begin);
      bitmap = (Bitmap)System.Drawing.Image.FromStream(stream);
      bitmap = bitmap.Clone(PixelFormat.Format32bppArgb);
  }
  </code></pre>