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!
WxSVG can rasterize? Topic is solved
-
- In need of some credit
- Posts: 2
- Joined: Sun Aug 23, 2020 8:22 am
Re: WxSVG can rasterize?
According to this small code snippet from the wxSVG site, it should work:
(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.
Code: Select all
wxSVGDocument* svgDoc = new wxSVGDocument;
svgDoc->Load(wxT("tiger.svg"));
wxImage img = svgDoc->Render();
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!
-
- In need of some credit
- Posts: 2
- Joined: Sun Aug 23, 2020 8:22 am
Re: WxSVG can rasterize?
No problem, i'm on Fedora.
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.
Re: WxSVG can rasterize?
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/nanosvgIt'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.
Use the source, Luke!
Re: WxSVG can rasterize?
Hi,
Regards,
David
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.I already tried nanosvg and librsvg
Regards,
David
- Attachments
-
- rsvg.cpp
- (6.44 KiB) Downloaded 184 times