[Mono-dev] gtk-dotnet performance

Jonathan Resnick jresnick at gmail.com
Wed Mar 1 11:47:43 EST 2006


Hello,
I tried posting a similar question to the Gtk list but haven't received any
response there, so I forgive me for trying my luck here as well.
 
I'm am trying to use gtk-dotnet functionality to copy a
System.Drawing.Bitmap to a Gtk.DrawingArea.
 
My first approach was to follow exactly the sample code provided on the mono
site (http://www.mono-project.com/GtkSharpNewInVersion2x):
 
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
	using (Graphics g = Gtk.DotNet.Graphics.FromDrawable (args.Window)){
            g.DrawImage(...);
      }
      return true;
}

However, I'm finding that the performance of this is unpredictable- if
several expose events are generated in quick succession (eg to create an
animation), the first will execute quickly ( < 100 msec) but the next 3 or 4
expose events will take much longer (~500 msec).

I thought there might be some overhead with re-creating the Graphics object
each time, so my second approach was to try using a static intermediate
Pixmap as follows:

// create a static pixmap
Pixmap pixmap = new Pixmap(...);
// create a static graphics object 
Graphics g = Gtk.DotNet.Graphics.FromDrawable (pixmap);

protected override bool OnExposeEvent (Gdk.EventExpose args)
{
	// Draw on the static pixmap, through the previously
	// created Graphics
	g.DrawImage(...);
	args.Window.DrawDrawable(..., pixmap, ...);
      return true;
}

However, in this case, the performance of g.DrawImage(...) drawing onto a
Pixmap is terrible (~ 1 second).

Basically, I just need a way to copy a System.Drawing.Bitmap to a
Gtk.DrawingArea in a constant and reasonably quick amount of time.  I'm not
sure what I'm doing wrong, but any ideas would be greatly appreciated.

-Jonathan




	





More information about the Mono-devel-list mailing list