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

blog vipa

System.Drawing.Image conversion to Gdk.Pixbuf

luty 27th, 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:

C#:
  1. private static Gdk.Pixbuf ImageToPixbuf(Image image)
  2. {
  3.   using (MemoryStream stream = new MemoryStream())
  4.   {
  5.     image.Save(stream, ImageFormat.Bmp);
  6.     stream.Position = 0;
  7.     Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(stream);
  8.     return pixbuf;
  9.   }
  10. }

Brak powiązanych wpisów

Leave a Reply