BufferedImage to JavaFX Image
我有一个从主显示器截取的图像,我想将其添加到Java FX中,如下所示:ImageView
@FXML
protected ImageView screenshot() throws AWTException, IOException {
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage capture = new Robot().createScreenCapture(screenRect);
ImageView imageView = new ImageView();
Image image = capture; //Error
imageView.setImage(image);
return imageView;
}
我正在尝试将 设置为,但类型不兼容,也无法强制转换。我该如何纠正这种情况?BufferedImage capture
javafx.scene.image.Image image