[cairo] Can't draw more

Gary Jaffe gfj555 at gmail.com
Sat Nov 24 11:09:49 PST 2007


Carl Worth wrote:
[snip...]
> 
> But if your question is whether it's appropriate to draw to a "backing
> pixmap" outside of the expose event and to then do nothing in the
> expose event but copy from that pixmap to the final destination---yes,
> that can be a perfectly valid way to structure a program. And you can
> use cairo for both the drawing and copying operations.
> 
> And if you do this, you can even turn off GTK+'s double buffering
> since you're doing double buffering yourself this way.
> 
> -Carl

Thanks for everyone responding.  You've all been a big help.  Sorry 
about being such a noobie about this, but I've hit a snag.

I want to be able to load a png file upon startup to use as a background 
and then draw on top of that image when the user clicks on buttons.  So 
in my __init__ routine (this is Python), I'm doing the following.
------------------------------------------------------------------------
self.bkgrndSurface = cairo.ImageSurface.create_from_png(
			"images/xxxxx.png")
------------------------------------------------------------------------

Then in my configure_event I'm doing
------------------------------------------------------------------------
x, y, width, height = widget.get_allocation()
self.context = widget.window.cairo_create()
self.context.rectangle(x, y, width, height)
self.context.clip()
self.context.set_source_surface(self.bkgrndSurface, 0, 0)
self.context.paint()
------------------------------------------------------------------------

and in my expose_event I'm doing
------------------------------------------------------------------------
self.context.set_source_surface(self.bkgrndSurface)
self.context.paint()
------------------------------------------------------------------------

What happens upon startup is that my png image flickers on the screen 
for a split second and then the image goes blank.  Can anyone see what 
I'm doing wrong?

Thanks,
Gary




More information about the cairo mailing list