views:

297

answers:

3

I need to be able to draw SVG images (with the ability to scale, and rotate the images by 90,180 and 270 degrees).

I also want the ability of instead of rendering the images to a bitmap (e.g. for displaying), to be able to draw them into a new SVG image (exporting the "document" to SVG).

wxWidgets does not seem to have any built in SVG capabilities, so I'm not sure how to proceed on adding such functionality.

A: 

You can render into a file in SVG format using wxSVGFileDC (http://docs.wxwidgets.org/trunk/classwx%5Fs%5Fv%5Fg%5Ffile%5Fd%5Fc.html) but there is no support for drawing SVG images, you will need to use an SVG rendering library and integrate it with wx (how to do this is platform-dependent).

Notice that wxSVGFileDC is in contrib, i.e. an additional library which needs to be built independently, in wx 2.8 but is in the main library itself in 2.9.

VZ
A: 

I'm not sure how practical this solution is, but one idea might be to embed wxWebKit in your application and then rely on WebKit's SVG support to do the rendering for you.

Phil Booth
+2  A: 

The cairo library website has examples on drawing SVG using librsvg.

Both the cairo and librsvg libraries should be sufficiently cross-platform to do what you need, and with wxcairo it should be possible to dock them onto wxWidgets.

That is the first idea I would research when faced with the task of drawing SVG into wxWidgets.

Also, drawing to SVG files with cairo is quite easy when you are doing all your drawing with cairo anyway, and the drawing model cairo uses is quite similar to SVG.

ndim