Hello,
I really think that it would be good to be able to draw a SVG directly
to a wxGraphicsContext.
For one of my projects, I have a custom component and would be happy to
switch to SVG, but don't know well if I'm getting it properly. For the
moment, I'm basically doing this:
wxImageBundle bundle = wxImageBundle::FromSVGFile("image.svg",
wxSize(100, 100));
wxBitmap bitmap = bundle.GetBitmap(wxSize(desiredWidth, desiredHeight));
graphicsContext->DrawBitmap(bitmap, desiredX, desiredY, desiredWidth,
desiredHeight);
Except that, of course, I load the SVG file only once and keep the
wxBitmapBundle object.
Desired width/height are known, they are computed based on available
client size. They are more or less fixed once computed, but may change
over time if the user resizes the window and/or change a few display
options of the program.
As far as what is possible right now witht the current wxWidgets
version, am I doing it right ?
For that kind of use, in fact, ideally, I don't care if the SVG is first
rendered on a bitmap first, or directly drawn without temporary bitmap.
IN that sense, being able to use a SVG renderer outside of
wxBitmapBundle would be good, I think. It would be probably even better
to be able to render a SVG by using directly wxGaphicsContext methods,
it should be possible, but it's clear that it isn't a so easy task as it
looks like.
I still don't understand well what to pass as size in
wxBitmapBundle::SVGFromFile, the 100x100 here is like a random choice
because I know in advance that the image is a square, but that's all. I
shouldn't be obliged to pass an hard-coded size here, if one day the
image has to be replaced by something rectangular.
I still don't understand why it would be bad to take the width/height or
viewBox attributes of the SVG as defaults when wxDefaultSize is passed.
And if, and only if no size is passed and there is no width/height or
viewBox to base on, then log an error.
Thank you.