Hi,

We've discussed adding image reading and writing functionality in the past. Something on the order of Java2D's Image I/O. Doing it right would be a large project, and would be more than just adding a couple methods to JavaFX Image. Unless and until we do that, using the SwingFXUtils to produce a BufferedImage from a JavaFX Image is the recommended approach.

-- Kevin


On 5/4/2021 5:08 AM, Frank Delporte wrote:
Hello

My first contribution to this mailing list... ;-)

During an experiment with FXGL on the Raspberry Pi + Gluon JavaFX 17-ea, it 
turned out there was a missing dependency to javafx.swing.
(also mentioned here 
<https://stackoverflow.com/questions/50900945/swingfxutils-alternative-for-image-serialization-javafx-swing-raspberry-pi>)

Turns out SwingFXUtils was used in the FXGL library only to be able to save a 
screenshot of the application to a file and we were able to rework it as you can see 
here: 
<https://github.com/AlmasB/FXGL/commit/737c2ba44b9c3e89ed29137ebe7f978b10ac782b>

I researched this topic for a few hours, but didn't manage to find a good 
approach to save a JavaFX Image. Maybe I missed something? Or wouldn't it be a 
good idea to extend the JavaFX Image or BufferedImage with e.g. 
writeToFile(ImageFormat.PNG), writeToFile(ImageFormat.JPG)?

Best regards
Frank Delporte

Want to have coding-fun?
Check my blog<https://webtechie.be/>and book "Getting started with Java on Raspberry 
Pi" on<https://webtechie.be/books/>



Reply via email to