Support pluggable image loading via javax.imageio
Michael Strauß
michaelstrau2 at gmail.com
Mon Apr 17 21:10:30 UTC 2023
Extending the image loading capabilities of JavaFX to support
additional image formats is a recurring question that still has no
good answer.
I've been working on a proposal that doesn't add any new API to
JavaFX, but instead plugs into the existing `javax.imageio` API,
allowing applications to use third-party libraries like TwelveMonkeys
[0] to load a wide variety of image formats.
The built-in JavaFX image loaders continue to be used for all
supported image formats. If an image can't be loaded using one of the
built-in loaders, JavaFX will probe the ImageIO registry for image
readers that can load the image instead.
The draft PR [1] also adds support for variable-density images like
SVG. Variable-density images will be rasterized using the screen's
pixel density, ensuring they are rendered at a higher resolution on
high-DPI screens.
The proposed feature works transparently across all JavaFX image APIs,
including images referenced by stylesheets, and images contained in
data-URIs.
I'm interested in your opinions on whether this is a useful feature to
add to JavaFX.
[0] https://github.com/haraldk/TwelveMonkeys
[1] https://github.com/openjdk/jfx/pull/1093
More information about the openjfx-dev
mailing list