The SVGimage class provides various ways to load and use SVG images in wxPython applications.
Creates a |
|
Automatically scales the SVG image so it will fit in the given size, |
|
Draw the collection of shapes and paths in the SVG image |
SVGimage
(SVGimageBase)¶The SVGimage class provides various ways to load and use SVG images in wxPython applications.
ConvertToBitmap
(self, tx=0.0, ty=0.0, scale=1.0, width=-1, height=-1, stride=-1)¶Creates a wx.Bitmap
containing a rasterized version of the SVG image.
tx (float) – Image horizontal offset (applied after scaling)
ty (float) – Image vertical offset (applied after scaling)
scale (float) – Image scale
width (int) – width of the image to render, defaults to width from the SVG file
height (int) – height of the image to render, defaults to height from the SVG file
stride (int) – number of bytes per scan line in the destination buffer, typically width * 4
ConvertToScaledBitmap
(self, size, window=None)¶Automatically scales the SVG image so it will fit in the given size,
and creates a wx.Bitmap
of that size, containing a rasterized
version of the SVG image. If a window is passed then the size of the
bitmap will automatically be adjusted to the content scale factor of
that window. For example, if a (32,32) pixel bitmap is requested for a
window on a Retina display, then a (64,64) pixel bitmap will be created.
RenderToGC
(self, ctx, scale=None, size=None)¶Draw the collection of shapes and paths in the SVG image
onto the given wx.GraphicsContext
using the drawing primitives
provided by the context. The Context’s state is saved and restored so
any transformations done while rendering the SVG will be undone.
ctx (wx.GraphicsContext) – The context to draw upon
scale (float) – If given, apply to the context’s scale.
float) size ((float,) – If given, scale the image’s width and height
to that provided in this parameter. Ignored if scale
is also specified.
Note
Some GraphicsContext backends perform better than others. The default GDI+ backend on Windows is the most glitchy, but the Direct2D backend works well.