blog vipa
mój dzień to 3 filiżanki kawy

blog vipa

System.Drawing.Image conversion to Gdk.Pixbuf

27 lutego, 2007 . by vip

Recently, I’ve been using ZedGraph under Gtk# to draw simple plots, but I’ve found a problem with displaing it under Gtk# forms, not the Windows.Forms. The (not) easiest thing, is to convert the plot to the bitmap image.

I’ve spent a lot of time searching for solution how to convert it to Pixbuf, the one is here:
private static Gdk.Pixbuf ImageToPixbuf(Image image)
using (MemoryStream stream = new MemoryStream())
image.Save(stream, ImageFormat.Bmp);
stream.Position = 0;
Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(stream);
return pixbuf;

Leave a Reply