Add method to save a JavaFX image to file without the use of SwingFXUtils?
John Neffenger
john at status6.com
Wed May 5 05:42:48 UTC 2021
On 5/4/21 5:08 AM, Frank Delporte wrote:
> I researched this topic for a few hours, but didn't manage to find a good approach to save a JavaFX Image.
For what it's worth, I ran 224 benchmarks to find the fastest method to
go in the other direction: read in an image using AWT and convert it to
a JavaFX image.
The results are posted here:
Benchmarks
https://jgneff.github.io/tofximage/
I found that the methods in SwingFXUtils are general enough that you can
almost always write them to be much, much faster for your specific case.
The code of the benchmarks is here:
AWT to JavaFX Image Conversion Benchmarks
https://github.com/jgneff/tofximage
If you don't care about the alpha channel, this method came out tops:
public void setArgbAsArgbPre(SourceAwtImage, ...)
https://github.com/jgneff/tofximage/blob/b40a1e01238f1431295716ca09e4c40b82ac95d9/src/main/java/org/status6/tofximage/Benchmarks.java#L475
That method is shown below in a real application:
public void handle(long now)
https://github.com/jgneff/epd-javafx/blob/master/src/org/status6/epd/javafx/ImageAnimation.java#L172
John
More information about the openjfx-dev
mailing list