title: WPF/WinForms/GDI interop: converting a WriteableBitmap to a System.Drawing.Image?
body: <p>How can I convert a WPF WriteableBitmap object to a System.Drawing.Image?</p>
  
  <p>My WPF client app sends bitmap data to a web service, and the web service needs to construct a System.Drawing.Image on that end.</p>
  
  <p>I know I can get the data of a WriteableBitmap, send the info over to the web service:</p>
  
  <pre><code>// WPF side:
  
  WriteableBitmap bitmap = ...;
  int width = bitmap.PixelWidth;
  int height = bitmap.PixelHeight;
  int[] pixels = bitmap.Pixels;
  
  myWebService.CreateBitmap(width, height, pixels);
  </code></pre>
  
  <p>But on the web service end, I don't know how to create a System.Drawing.Image from this data.</p>
  
  <pre><code>// Web service side:
  
  public void CreateBitmap(int[] wpfBitmapPixels, int width, int height)
  {
     System.Drawing.Bitmap bitmap = ? // How can I create this?
  }
  </code></pre>