[Gtk-sharp-list] Cairo ExposeEvent & DrawinArea scrolling problem.

Marcin S msporysz06 at gmail.com
Sun Jul 15 15:16:27 UTC 2012


Hi ppls!
Mind this OnExposeEvent code

        void OnCanExposeEvent (object o, ExposeEventArgs args)
        {

/*
* surface and img2 are initialized in ctor. (2 png images from file)
*/
Context ctx2 = new Context(surface);
ctx2.SetSourceSurface(img2,10,10);
ctx2.Rectangle(10,10,15,15);
ctx2.Clip();
ctx2.Paint();


            DrawingArea ar = (DrawingArea) o;
            Context ctx = Gdk.CairoHelper.Create(ar.GdkWindow);

ctx.Antialias = Antialias.None;

ctx.Source = new SurfacePattern(surface);
ctx.Paint();

            ((IDisposable) ctx2.Target).Dispose ();
            ((IDisposable) ctx2).Dispose ();
            ((IDisposable) ctx.Target).Dispose ();
            ((IDisposable) ctx).Dispose ();
        }

Now 2 words of explanation. I have 2 pcs of ImageSurface, "surface"
and "img2" both are private members, loaded from png files in class
ctor.
What i want to achieve is to draw one image on top another and then
render it in given DrawingArea

There are 2 Contexts in the event.
ctx2: source set to "img2" image, and target set to "surface" image.
ctx: source set to "surface" and target set to DrawingArea.

when i launch the program, everything renders just fine, but when i
redraw DrawingArea widget (by invoking QueueDraw()) image disappears -
also when i scroll drawing area down and then up again, then
previously covered fragment of image disappears as well :/

Whats even more strange, when i comment last 4 lines (disposing procs)
everything is working as expected (beside getting ton of console
warnings im not disposing)

Any idea how to solve this?
Or maybe suggest another apporach to drawing images on top of images,
maybe i get it wrong.


More information about the Gtk-sharp-list mailing list