[cairo] cairo_surface_create_similar / create_similar for SVGSurface

Steve stevech1097 at yahoo.com.au
Tue Jul 1 18:47:43 PDT 2008


On Tue, 2008-07-01 at 04:20 -0700, cairo-request at cairographics.org
wrote:
> I'm using multiple surfaces to render some diagrams to an SVG, but the
> SVG
> surface doesn't seem to support the create_similar method for the
> CONTENT_COLOR
> or CONTENT_COLOR_ALPHA options.  Is there an option that I'm missing?
> 
> Thanks,
> 
> Eric
You don't show which error message you get, or which cairo and pycairo
version you use, so your problem description is a bit vague.

It was discussed before
http://www.nabble.com/How-should-bindings-deal-with-surfaces-of-unknown-type--tp13082710p13082710.html
A solution was proposed for inclusion in cairo 1.6, but AFAIK it has not
been implemented yet. I suggest opening a cairo bug report to remind the
developers it still needs fixing.

Regards,
Steve

> # this works fine
> s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 400)
> 
> # this fails when I tried to call the create_similar
> s = cairo.SVGSurface(strFileName, 400, 400)
> 
> ctx = cairo.Context(s)
> 
> target  = ctx.get_target()
> layer0 = target.create_similar(cairo.CONTENT_COLOR_ALPHA, 400, 400)
> layer1 = target.create_similar(cairo.CONTENT_COLOR_ALPHA, 400, 400)
> 
> # render layers
> # ...
> 
> # Add the layers back to the original surface
> ctx.set_operator(cairo.OPERATOR_OVER)
> ctx.set_source_surface(layer0, 0, 0)
> ctx.paint()
> 
> ctx.set_operator(cairo.OPERATOR_OVER)
> ctx.set_source_surface(layer1, 0, 0)
> ctx.paint()
> 



More information about the cairo mailing list