Fix #2665: newBuiltinImage 不应缓存经缩放的图像 (#2668)

This commit is contained in:
Glavo
2024-01-22 21:09:26 +08:00
committed by GitHub
parent ddcead7c85
commit 9bdf08af1e

View File

@@ -686,7 +686,13 @@ public final class FXUtils {
* @see ResourceNotFoundError
*/
public static Image newBuiltinImage(String url) {
return newBuiltinImage(url, 0, 0, false, false);
return builtinImageCache.computeIfAbsent(url, s -> {
try {
return new Image(s);
} catch (IllegalArgumentException e) {
throw new ResourceNotFoundError("Cannot access image: " + s, e);
}
});
}
/**
@@ -706,13 +712,11 @@ public final class FXUtils {
* @see ResourceNotFoundError
*/
public static Image newBuiltinImage(String url, double requestedWidth, double requestedHeight, boolean preserveRatio, boolean smooth) {
return builtinImageCache.computeIfAbsent(url, s -> {
try {
return new Image(s, requestedWidth, requestedHeight, preserveRatio, smooth);
} catch (IllegalArgumentException e) {
throw new ResourceNotFoundError("Cannot access image: " + s, e);
}
});
try {
return new Image(url, requestedWidth, requestedHeight, preserveRatio, smooth);
} catch (IllegalArgumentException e) {
throw new ResourceNotFoundError("Cannot access image: " + url, e);
}
}
/**