GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lanthale/LibHeifFX: This installs the native lib libheif as a JavaFX Image format provider similar to imageIO before on Swing

BranchesTags
Open more actions menu

Latest commit

 

History

76 Commits
76 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
LibHeifFX
LibHeifFX
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

LibHeifFX

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.

Donate

JDK 25 and JavaFX 25 is required for v1.3.1 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

Status

Now the lib is in release status. That means it is tested on OSX, Windows, Ubuntu 20.4 under different threading scenarious.

Supported OS:

  • Linux (min. glibc 2.27 which means Ubuntu 18 or later)
  • OSX up to 12.5 including Apple M1
  • Windows 10/11

I have integrated Libheif 1.12.0 (https://github.com/strukturag/libheif/releases/tag/v1.12.0)

Open topics

  • AVIF is not recognized as a valid image file format

Usage

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.3.1</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
  • add the following lines to your java config for JDK25:
--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
  • Module name: 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).

Steps to create your own build:

  • OpenJDK/Adoptium 25
  • JavaFX 25
  • SET JAVA_HOME variable
  • Execute mvn clean compile package -f LibHeifFX/pom.xml
  • To run the example execute mvn javafx:run@cli-default
  • IDE Integration: execute as a maven goal javafx:run@ide-debug or javafx:run@ide-profile

Notes:

  • The orginal C interface was changed to get it working with project panama
  • The lib is using heavily the foreign memory API from Java 21 including functions from the project Panama and therefore the tool JExtract (Must be build separately)
  • Inside of these package org.libheif.nativ above I exposed also the raw interface to libheif
  • The main class to interact with the native lib is the class LibHeifImage.java in package org.libheiffx

JFXCentral

About

This installs the native lib libheif as a JavaFX Image format provider similar to imageIO before on Swing

Resources

Readme
LGPL-2.1 license
Activity

Stars

12 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.