<div dir="ltr"><div>Hello,</div><div dir="ltr"><br></div><div dir="ltr">Thank you for the clarification.</div><div dir="ltr">I thought the width and height in the loader referred to the preferred size.<br><br>Since SVG is essentially XML, manipulating it at runtime is straightforward.<br>We can generate an image at a specific breakpoint and change it using a data URI.<br>Additionally, viewport media support will likely provide even more flexibility.<br><br>.pane {<br> -fx-background-image: url("/image.svg");<br>}<br><br>@media (<span id="m_-2618492506973352196:ip.1" role="menuitem" aria-haspopup="true">812px</span> <= width <= 1024px) {<br> .pane {<br> -fx-background-image: url("/image-x2.svg");<br> }<br>}<br><br>I created a demo repository that demonstrates loading and transforming SVG using the jsvg library.<br><br><a href="https://github.com/mkpaz/jsvgfx" target="_blank">https://github.com/mkpaz/jsvgfx</a><br><br>Best regards.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пн, 14 июл. 2025 г. в 21:35, Michael Strauß <<a href="mailto:michaelstrau2@gmail.com" target="_blank">michaelstrau2@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A JavaFX Image always has a fixed size. Usually, this will be the<br>
intrinsic size of the image, but it can also be any other size if the<br>
image is created with the constructor that takes requestedWidth and<br>
requestedHeight.<br>
Internally, the JavaFX Image is stored with an arbitrary pixel<br>
density. There's exactly two ways how you can end up with a pixel<br>
density > 1:<br>
a) use the @Nx image naming convention<br>
b) use a variable-density image loader on a high-DPI screen<br>
<br>
Importantly, you won't get a "dynamic" image if you do that (meaning<br>
an image that can have different render sizes), you simply get a<br>
normal JavaFX Image that is loaded with a higher pixel density.<br>
This means that if you have a variable-density image loader and<br>
canSetSourceRenderSize() is true, J2DImageLoader scales the intrinsic<br>
size of the image (or the requested size) with the screen DPI.<br>
<br>
A JavaFX Image is not a scene graph node, it doesn't know about where<br>
it is used and how large it ends up on the screen.<br>
<br>
I think what you're asking for is one of two things (or both things at once):<br>
<br>
1. Allow multiple versions of an image loaded at the same time, and<br>
defer selection until render time. Then choose the best version<br>
depending on the transformed size of the rendered image. This would<br>
work for discrete versions like you get with the @Nx naming<br>
convention.<br>
2. Allow an image to be dynamically rasterized from source depending<br>
on the transformed size of the rendered image. This would work for<br>
variable-density images.<br>
<br>
I think that the first option would be a good enhancement. The second<br>
option seems much harder to achieve.<br>
<br>
<br>
<br>
On Mon, Jul 14, 2025 at 3:20 PM mkpaz <<a href="mailto:quizynox@gmail.com" target="_blank">quizynox@gmail.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> I'm testing the new pluggable image API with SVG and noticed one thing.<br>
> Since SVG is a scalable vector format, it can be rendered at an arbitrary size.<br>
> For this purpose, we need to know the frame (pane) size and scale the image accordingly while rendering.<br>
> As I understand, ImageReadParam is used to pass the frame size to the image reader.<br>
><br>
> public class ImageReadParam extends IIOParam {<br>
> /**<br>
> * Returns {@code true} if this reader allows the source image to be rendered at an<br>
> * arbitrary size as part of the decoding process ...<br>
> */<br>
> public boolean canSetSourceRenderSize() {<br>
> return canSetSourceRenderSize;<br>
> }<br>
> }<br>
><br>
> But when I set canSetSourceRenderSize to true to activate this, I don't get the client frame size.<br>
> Instead, I get the actual image size, which the reader already knows since it implements the getWidth() and getHeight() methods.<br>
><br>
> I read the code and came across this:<br>
> <a href="https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/javafx/iio/java2d/J2DImageLoader.java#L122" rel="noreferrer" target="_blank">https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/javafx/iio/java2d/J2DImageLoader.java#L122</a><br>
><br>
> Why does the image loader use the reader's width and height in both branches?<br>
> Shouldn't the loader provide the frame size when canSetSourceRenderSize returns true?<br>
> Maybe I'm looking for something that isn't supported? Yet?<br>
><br>
> Best regards.<br>
</blockquote></div>
</div>