SVGLoader.load
static methods. For example: SVGImage img = SVGLoader.load(<my SVG file>);The SVGImage result is a JavaFX Group.
load
static methods. You can also specify how you want to load the SVG content by using the LoaderParameters class.
SVGImage
result can be converted to a JavaFX Image. The simplest way to perform the conversion is by using the toImage
method. For example: SVGImage img = SVGLoader.load(<my SVG file>); Image fxImg = img.toImage();Several conversion methods allow to specify the width of the resulting image (keeping the form factor), or scaling the image. For example:
SVGImage img = SVGLoader.load(<my SVG file>); Image fxImg = img.toImage(100); // the resulting image will have a width of 100 pixels Image fxImg2 = img.toImageScaled(0.5d); // the resulting image will be scaled by a 0.5 factor Image fxImg2 = img.toImage(ScaleQuality.RENDER_QUALITY, 50); // the resulting image will have a width of 50 pixelsIt is also possible to use the JavaFX
SnapshotParameters
to customize the resulting image.
id
attribute can be accessed through the getNode(id)
method in the SVGImage result.
Copyright 2021-2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD-3-Clause License