You can do it via non public API much faster. You can have a look into LibrawFX 
or LibHeifFX. 

What would help is to make the existing API public. 

Clemens

> On 18. Apr 2023, at 17:51, John Neffenger <j...@status6.com> wrote:
> 
> On 4/17/23 2:10 PM, Michael Strauß wrote:
>> I've been working on a proposal that doesn't add any new API to
>> JavaFX, but instead plugs into the existing `javax.imageio` API,
>> allowing applications to use third-party libraries like TwelveMonkeys
>> [0] to load a wide variety of image formats.
> 
> Looks interesting! Just in case it's helpful, I tested 14 different ways of 
> converting AWT images to JavaFX images using the public APIs. The latest 
> results are here:
> 
>  Benchmarks - September 2020 - toFXImage
>  https://jgneff.github.io/tofximage/2020-09/
> 
> The source code for all of the tests is found here:
> 
>  Benchmarks.java
> https://github.com/jgneff/tofximage/blob/master/src/main/java/org/status6/tofximage/Benchmarks.java
> 
> I see you're using 'for' loops in your 'BufferedImageConverter' class to 
> convert the pixels. Unlike yours, the 'for' loops in my tests were making two 
> method calls for each pixel, so they were the slowest by far:
> 
>    PixelWriter writer = jfxImage.getPixelWriter();
>    for (int y = 0; y < awt.height; y++) {
>        for (int x = 0; x < awt.width; x++) {
>            writer.setArgb(x, y, awtImage.getRGB(x, y));
>        }
>    }
> 
> The 'for' loops you're using might be optimized by the JIT compiler more 
> easily. In my tests, though, I found that letting a PixelWriter do the 
> conversion on the entire pixel array in one call was the fastest. If I 
> remember correctly, it dropped into native code for the actual conversion and 
> copying:
> 
>    int[] data = ((DataBufferInt)
>            awtImage.getRaster().getDataBuffer()).getData();
>    jfxImage.getPixelWriter().setPixels(0, 0, width, height,
>            format, data, 0, width);
> 
> John
> 

Reply via email to