[cairo] cairo_surface_create_similar / create_similarfor SVGSurface

Eric Holmberg eric at omnicurious.com
Tue Jul 1 20:44:06 PDT 2008


Steve <stevech1097 <at> yahoo.com.au> writes:
> 
> 
> 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.

Sorry for the vague problem -- I figured I was doing something wrong since I'm
new to Cairo.

The actual error returned is:
    layer0 = target.create_similar(cairo.CONTENT_COLOR_ALPHA, 400, 400)
cairo.Error: Unsupported Surface type

And this occurs with:
 PyCairo:  '1.4.0'
 Cairo:     1.6.0

> 
> 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.


Thanks for the link -- this is the error that I was seeing.  I'm not sure why
the Python bindings are revision 1.4.0, but the Cairo library is 1.6.0.  I would
gladly open a bug report as long as I'm not wasting the developers' time.

-Eric 



> > # 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