【问题标题】:How to convert WritableImage to ImageView in javaFX?如何在 javaFX 中将 WritableImage 转换为 ImageView?
【发布时间】:2021-09-24 22:37:03
【问题描述】:
您好 Stackoverflow 成员,祝您有美好的一天。有没有办法将可写图像对象转换或转换为ImageView,以便在我的程序中显示它,而无需将图像保存在硬盘上。
WritableImage writable_image = barchart.snapshot(new SnapshotParameters(), null);
我需要将 writable_image 转换为 ImaveView 对象的东西。
【问题讨论】:
标签:
image
javafx
casting
imageview
png
【解决方案1】:
您不会将 WritableImage 转换为 ImageView。 ImageView 是一个 UI 组件,旨在显示 Image。因为WritableImage 扩展了Image,所以你不需要做任何特别的事情。
ImageView imageView = ...;
WritableImage writableImage = barchart.snapshot(new SnapshotParameters(), null);
imageView.setImage(writableImage);