Add simple wxBitmapBundle::FromSVG() implementation using NanoSVG

Add nanosvg submodule and use it in the generic implementation of this
function.

This is incomplete yet and, notably, doesn't cache the rasterized
images, but already shows that using SVG images works (at least in the
toolbar sample).
This commit is contained in:
Vadim Zeitlin
2021-09-28 18:03:55 +01:00
parent 5ebd76156d
commit ac02ae877f
17 changed files with 369 additions and 27 deletions

View File

@@ -176,6 +176,35 @@ public:
*/
static wxBitmapBundle FromResources(const wxString& name);
/**
Create a bundle from the SVG image.
Please note that the current implementation uses NanoSVG library
(https://github.com/memononen/nanosvg) for parsing and rasterizing SVG
images which imposes the following limitations:
- Text elements are not supported at all.
- SVG 1.1 filters are not supported.
These limitations will be relaxed in the future wxWidgets versions.
Please also note that this method is only available in the ports
providing raw bitmap access via wxPixelData and so defining
wxHAS_RAW_BITMAP symbol. Currently SVG images are not supported in the
ports without it, e.g. wxX11.
@param data This data may, or not, have the XML document preamble, i.e.
it can start either with @c "<?xml" processing instruction or
directly with @c svg tag. Notice that the pointer is non-const as
the current implementation modifies it while parsing, i.e. do @a
not use @c const_cast to pass data that is actually const to this
function.
@param sizeDef The default size to return from GetDefaultSize() for
this bundle. As SVG images usually don't have any natural
default size, it should be provided when creating the bundle.
*/
static wxBitmapBundle FromSVG(char* data, const wxSize sizeDef);
/**
Check if bitmap bundle is non-empty.