[wxSVG] Centering an Image 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
User avatar
Deluge
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 30, 2010 4:52 am
Location: USA
Contact:

[wxSVG] Centering an Image

Post by Deluge »

Anyone familiar with wxSVG? I can't figure out how to center the image of a wxSVGCtrl. It always renders in the top-left corner. I've found some documentation here: http://wxsvg.sourcearchive.com/document ... GCtrl.html

I thought that if I could get hold of the underlying wxBitmap I could center it on its parent, but the bitmap image (m_buffer) is protected and I can't access it. And I don't see any public functions that would allow me to access it.

I've tried accesing the wxSVGDocument as well. But I can't see anything from there that would allow me to center the image.

----- Edit

What is it that I need to center? The wxSVGDocument, the wxBitmap, the wxSVGMatrix, ...?
Last edited by Deluge on Fri Jun 21, 2019 8:21 am, edited 2 times in total.
Projects:
Debreate
MyABCs
Stendhal

OSes:
Windows 10 Home (missing my Linux & Freebsd :()
User avatar
Deluge
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 30, 2010 4:52 am
Location: USA
Contact:

Re: [wxSVG] Centering an Image

Post by Deluge »

This is very old. But I recently started working on an old project & found an answer. The method that I used for centering an SVG image with wxSVG is to create a wxSVGDocument then render it to a wxImage & load it into a wxStaticBitmap:

Code: Select all

wxString filename = "example.svg";
wxSVGDocument* svgdoc = new wxSVGDocument();
svgdoc->Load(filename);
wxImage image = svgdoc->Render();
wxStaticBitmap* bitmap = new wxStaticBitmap();
bitmap->SetBitmap(wxBitmap(image));
Then I can position the wxStaticBitmap how I want.
Projects:
Debreate
MyABCs
Stendhal

OSes:
Windows 10 Home (missing my Linux & Freebsd :()
Post Reply