[cairo] gtk, cairo and surfaces
Gerdus van Zyl
gerdusvanzyl at gmail.com
Sat May 23 04:10:16 PDT 2009
I seem to remember the following also working (on win32 not sure about gtk):
tsurf = ctx.get_target() #get surface from context
Just as an aside the code you listed:
## Trying to 'capture' my self.context into a pattern.
will not work because push/pop group only captures cairo calls
betweeen them, so you would need to repeat the drawing between those
On Sat, May 23, 2009 at 12:48 PM, Hakki Dogusan <dogusanh at tr.net> wrote:
> Donn wrote:
>> Sorry if I am being thick, but I can't get anywhere with this. I am scraping
>> the net far and wide, so perhaps something will come-up.
>> I am using pygtk and python-cairo. I have a DrawingArea which gets an expose
>> event. In that event one draws stuff with a context; there is no hint of
>> where/what the surface is (I can't find any).
>> I want to output a png of what is being drawn to the window. Can anyone point
>> me in the right direction?
>> Some code:
>> class Stack(gtk.DrawingArea):
>> def _expose(self, widget, event):
>> self.context = widget.window.cairo_create()
>> Draw stuff to self.context ...
> Take this drawing commands to a subroutine,ie. DrawStuff(ctx). Call it here:
>>[snipped rest of def _expose
> Write a subroutine for png out, ie.
> def OutToPNG()
> out = cairo.ImageSurface(cairo.FORMAT_ARGB32,self.w,self.h)
> ctxout = cairo.Context( out )
> out.write_to_png("somefile%d.png" % self.outpic )
> self.outpic += 1
> destroy ctxout
> destroy out
> Hakki Dogusan
> cairo mailing list
> cairo at cairographics.org
More information about the cairo