Tuesday, January 8, 2013

Convert java.awt.image.BufferedImage to javafx.scene.image.Image

To convert image from java.awt.image.BufferedImage to javafx.scene.image.Image, SwingFXUtils.toFXImage() can be used.

Example:
            BufferedImage bufferedImage = ImageIO.read(file);
            Image image = SwingFXUtils.toFXImage(bufferedImage, null);
            myImageView.setImage(image);


Related:
- Get width and height of javafx.scene.image.Image


4 comments: