How do you convert a Gdk.Pixbuf
(_pixbuf below) into a Windows Forms (System.Drawing
) Bitmap? Below is code that uses Gtk.DotNet.Graphics
, but it just gives a white image. Is there a better, more direct way, that works? I'm using C# on Mono, but I can convert if you have an answer in another language.
public System.Drawing.Bitmap toBitmap () {
Gdk.Pixmap pixmap, mask;
_pixbuf.RenderPixmapAndMask(out pixmap, out mask, 255);
System.Drawing.Graphics graphics = Gtk.DotNet.Graphics.FromDrawable(pixmap);
return new System.Drawing.Bitmap(width, height, graphics);
}