title: Converting Bitmap to GDK# PixBuff
body: <p>How can I convert a <code>System.Drawing.Bitmap</code> to <code>GDK# Image</code> so that I can set to the image widget.</p>
  
  <p>I have tried this...</p>
  
  <pre><code>System.Drawing.Bitmap b = new Bitmap (1, 1);
  Gdk.Image bmp = new Gdk.Image (b);
  </code></pre>
  
  <p>UPDATE:</p>
  
  <pre><code>Bitmap bmp=new Bitmap(50,50);
          Graphics g=Graphics.FromImage(bmp);
          System.Drawing.Font ff= new System.Drawing.Font (System.Drawing.FontFamily.GenericMonospace, 12.0F, FontStyle.Italic, GraphicsUnit.Pixel);
          g.DrawString("hello world",ff,Brushes.Red,new PointF(0,0));
          MemoryStream ms = new MemoryStream ();
          bmp.Save (ms, ImageFormat.Png);
          Gdk.Pixbuf pb= new Gdk.Pixbuf (ms); 
          image1.Pixbuf=pb;
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; GLib.GException: Unrecognized image file format
     at Gdk.PixbufLoader.Close()
     at Gdk.PixbufLoader.InitFromStream(Stream stream)
     at Gdk.PixbufLoader..ctor(Stream stream)
     at Gdk.Pixbuf..ctor(Stream stream)
  </code></pre>