Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing SVG images in wxWidgets

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.

like image 298
Fire Lancer Avatar asked Dec 17 '09 13:12

Fire Lancer


2 Answers

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.

like image 108
ndim Avatar answered Sep 19 '22 14:09

ndim


You can render into a file in SVG format using wxSVGFileDC (http://docs.wxwidgets.org/trunk/classwx_s_v_g_file_d_c.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.

like image 37
VZ. Avatar answered Sep 18 '22 14:09

VZ.