WxSVG can rasterize? Topic is solved

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
SuperGabry64
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Aug 23, 2020 8:22 am

WxSVG can rasterize?

Post by SuperGabry64 »

I am new to c++, SFML, and wxWidget, and because I am trying to use SFML and SVG files, that doesn't are compatible, I have searched and found wxsvg, so I'm asking if it can rasterize (convert) an SVG file to png?

I already tried nanosvg and librsvg but I can't use none of them!
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxSVG can rasterize?

Post by doublemax »

According to this small code snippet from the wxSVG site, it should work:

Code: Select all

wxSVGDocument* svgDoc = new wxSVGDocument;
svgDoc->Load(wxT("tiger.svg"));
wxImage img = svgDoc->Render();
(You can save a wxImage to PNG).

Beware that wxSVG requires Cairo even under Windows, which makes it a pain to use there.

BTW: What was your issue with NanoSVG? I know it's not complete and doesn't render all SVGs correctly, but it should be relatively easy to use.
Use the source, Luke!
SuperGabry64
In need of some credit
In need of some credit
Posts: 2
Joined: Sun Aug 23, 2020 8:22 am

Re: WxSVG can rasterize?

Post by SuperGabry64 »

doublemax wrote: Sun Aug 23, 2020 9:17 am Beware that wxSVG requires Cairo even under Windows, which makes it a pain to use there.
No problem, i'm on Fedora.
doublemax wrote: Sun Aug 23, 2020 9:17 am BTW: What was your issue with NanoSVG? I know it's not complete and doesn't render all SVGs correctly, but it should be relatively easy to use.
It's that a it has a lot of dependences plus a compiler, and in much of the times the package name is writed for ubuntu/debian and not for fedora/rhel/centos.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxSVG can rasterize?

Post by doublemax »

It's that a it has a lot of dependences plus a compiler, and in much of the times the package name is writed for ubuntu/debian and not for fedora/rhel/centos.
Then you must be talking about another project. The nanosvg i'm thinking of has no dependecies whatsoever and only consists of two header files. https://github.com/memononen/nanosvg
Use the source, Luke!
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: WxSVG can rasterize?

Post by DavidHart »

Hi,
I already tried nanosvg and librsvg
I had a similar requirement a couple of years ago, to implement image preview for .svg files in 4Pane. I forget why I couldn't simply use just librsvg direct, but I succeeded by also copying and truncating code from the rsvn binary. I've attached that file; you can see it in action in 4Pane (it's in fedora) and the source-code is here.

Regards,

David
Attachments
rsvg.cpp
(6.44 KiB) Downloaded 181 times
Post Reply