[Mono-dev] Mono/C# pointer for using Gdk/Pixbuf

Cody Russell bratsche at gnome.org
Fri Nov 10 01:19:07 EST 2006

On Thu, 2006-11-09 at 18:10 -0800, Mark E Mason wrote:
> Hello all,
> I'm looking for a pointer for doing low-level drawing in a Mono/C#
> application developed under MonoDevelop.  Basically, all I need to do is
> allocate a pixel buffer, manually set specific pixels to specific
> colors, and have it drawn correctly in whatever widget it's attached to.
> [Basically I'm taking the results of numerical functions, and
> representing them as colors in a pixmap].
> I've been looking at using a Pixbuf (or was it Pixmap) and a DrawingArea
> widget, but  getting a handle on where to start has been difficult (ie.
> How to blit the pixmap into the DrawingArea after an expose event, etc).
> I looked at Cairo briefly, but even the docs at go-mono says it's
> overkill for what I'm doing.
> Any pointers or advice greatly appreciated.

I think you want to start with something like this:

class MyDrawingArea : Gtk.DrawingArea
  Gdk.Pixbuf mypixbuf;

  void OnExposed (object o, ExposeEventArgs args)
    mypixbuf.RenderToDrawable (this.GdkWindow, Style.WhiteGC,
                               0, 0, x, y, w, h, RgbDither.None, 0, 0);

Look up Gdk.Pixbuf on http://www.go-mono.com/docs/ and read about its
member RenderToDrawable for more details.

/ Cody

More information about the Mono-devel-list mailing list