Integration of Libheif (https://github.com/strukturag/libheif) library for JavaFX for all major operating systems (Linux, Windows, OSX). All flavoris of heif formats can be loaded with the Image class and manipulated by Pixelwriter/Pixelreader. Limitation is that the image class only supports 8-bit color deph but converts all 16bit image format to 8bit automatically.
JDK 24 and JavaFX 24 is required for v1.2.7 because of the foreign linker API usage and important changes (Windows) for threading happenend in Panama in JDK21
JDK 18 is required for v1.1.9 because of the foreign linker API usage and the big changes for threading happenend in Panama in JDK18
Now the lib is in release status. That means it is tested on OSX, Windows, Ubuntu 20.4 under different threading scenarious.
Supported OS:
I have integrated Libheif 1.12.0 (https://github.com/strukturag/libheif/releases/tag/v1.12.0)
Point to the maven coordinates:
JDK18
<dependency>
<groupId>org.libheiffx</groupId>
<artifactId>LibHeifFX</artifactId>
<version>1.1.9</version>
</dependency>
JDK24
<dependency>
<groupId>org.libheiffx</groupId>
<artifactId>LibHeifFX</artifactId>
<version>1.2.7</version>
</dependency>
In the Class where the start method is add as one of the first lines the following code to install the file handler:
HEIFImageLoaderFactory.install();
and add the following lines to your java config for JDK18:
--add-modules jdk.incubator.foreign --enable-native-access=org.libheiffx
--add-exports=javafx.graphics/com.sun.javafx.iio=org.libheiffx
--add-exports=javafx.graphics/com.sun.javafx.iio.common=org.libheiffx
--enable-preview
--enable-native-access=org.libheiffx
--add-exports=javafx.graphics/com.sun.javafx.iio=org.libheiffx
--add-exports=javafx.graphics/com.sun.javafx.iio.common=org.libheiffx
You can have a look into the class TestAPP.java to see how to use it, but generally just create an Image with the URL/stream and add it to the image view:
Image img=new Image(initialFile.toURI().toURL().toString(), false);
ImageView view = new ImageView();
view.setFitHeight(200);
view.setFitWidth(200);
view.setPreserveRatio(true);
stack.getChildren().add(view);
view.setImage(img);
You can also use the lib without adding the file handler. What I mean is that you can also forget the "...install" line and just load a file URL with the lib (see the TestApp.java
to see how it works).
mvn clean compile package -f LibHeifFX/pom.xml
mvn javafx:run@cli-default
javafx:run@ide-debug
or javafx:run@ide-profile
JExtract
(Must be build separately)org.libheif.win
/ org.libheif.nativ
are generated by jextract but tuned for operating system specificaLibHeifImage.java
in package org.libheiffx
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3