Convert JavaFX image To BufferedImage


Question

I'm trying to convert an JavaFX Image(from ImageView) to an BufferedImage. I tried casting and stuff but nothing works. Can someone suggest how i should do this?

1
9
5/30/2014 1:13:51 PM

Accepted Answer

Try your luck with SwingFXUtils. There is a method for that purpose:

BufferedImage fromFXImage(Image img, BufferedImage bimg)

You can call it with second parameter null, as it is optional (exists for memory reuse reason):

BufferedImage image = SwingFXUtils.fromFXImage(fxImage, null);
28
2/4/2014 9:12:40 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon