Open ctoabidmaqbool opened 1 year ago
Hi! I think it's more like a JavaFx issue rather then jPro!
The ImageView -> setPreserveRatio(true) is a very nice feature of javafx. But in the case of SVG image, it's not working as expected.
ImageView -> setPreserveRatio(true)
Sample code:
@Override public void start(Stage stage) throws FileNotFoundException { StackPane stackPane = new StackPane(); Image image = new Image("https://images6.alphacoders.com/317/317793.jpg", true); ImageView imageView = new ImageView(new Image("https://www.svgrepo.com/show/512360/image-picture-971.svg")); imageView.setFitWidth(300); imageView.setFitHeight(400); imageView.setPreserveRatio(false); image.progressProperty().addListener((observable, oldValue, newValue) -> { if ((Double) newValue == 1.0 && !image.isError()) { imageView.setImage(image); imageView.setPreserveRatio(true); } }); image.errorProperty().addListener((observable, oldValue, newValue) -> { }); image.exceptionProperty().addListener((observable, oldValue, newValue) -> { }); stackPane.getChildren().add(imageView); Scene scene = new Scene(stackPane); stage.setScene(scene); stage.show(); }
Simple SVG Image with setPreserveRatio(false):
setPreserveRatio(false)
JPG image after finish loading:
Simple SVG Image with setPreserveRatio(true):
setPreserveRatio(true)
Hi! I think it's more like a JavaFx issue rather then jPro!
The
ImageView -> setPreserveRatio(true)
is a very nice feature of javafx. But in the case of SVG image, it's not working as expected.Sample code:
Simple SVG Image with
setPreserveRatio(false)
:JPG image after finish loading:
Simple SVG Image with
setPreserveRatio(true)
: