Skip to content

Commit

Permalink
Merge pull request #7 from nextbreakpoint/dev/3.18.0-2.2
Browse files Browse the repository at this point in the history
change package name. rename examples and tests modules
  • Loading branch information
nextbreakpoint authored Jul 16, 2024
2 parents 4683363 + b69b554 commit 4a780b2
Show file tree
Hide file tree
Showing 183 changed files with 524 additions and 1,097 deletions.
16 changes: 4 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
/freeimage4java-windows/src/main/resources/freeimage4java.dll
/freeimage4java-linux/src/main/resources/libfreeimage4java.so
/freeimage4java-macos/src/main/resources/libfreeimage4java.dylib
/freeimage4java-macos-test/test0.png
/freeimage4java-macos-test/test1.png
/freeimage4java-macos-test/test2.png
/freeimage4java-linux-test/test0.png
/freeimage4java-linux-test/test1.png
/freeimage4java-linux-test/test2.png
/freeimage4java-windows-test/test0.png
/freeimage4java-windows-test/test1.png
/freeimage4java-windows-test/test2.png
/freeimage4java-macos-examples/output.png
/freeimage4java-linux-examples/output.png
/freeimage4java-windows-examples/output.png
/freeimage4java-examples/output.png
/freeimage4java-tests/test0.png
/freeimage4java-tests/test1.png
/freeimage4java-tests/test2.png
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ dump:
verify:
test $(system)
@echo System = $(system)
#MAVEN_OPTS="--enable-preview --enable-native-access=ALL-UNNAMED -Djava.library.path=freeimage4java-$(system)-test/target/lib -Djextract.trace.downcalls=false -Xlog:library" mvn verify -P$(system);
MAVEN_OPTS="--enable-preview --enable-native-access=ALL-UNNAMED -Djava.library.path=freeimage4java-$(system)-test/target/lib -Djextract.trace.downcalls=false $(properties)" mvn verify -P$(system);
#MAVEN_OPTS="--enable-preview --enable-native-access=ALL-UNNAMED -Djava.library.path=freeimage4java-tests/target/lib -Djextract.trace.downcalls=false -Xlog:library" mvn verify -P$(system);
MAVEN_OPTS="--enable-preview --enable-native-access=ALL-UNNAMED -Djava.library.path=freeimage4java-tests/target/lib -Djextract.trace.downcalls=false $(properties)" mvn verify -P$(system);

.PHONY: copy-legal
copy-legal:
Expand Down
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# FreeImage4Java 3.18.0-2.1
# FreeImage4Java 3.18.0-2.2

FreeImage4Java provides a Java wrapper of FreeImage library version 3.18.0.

Please note that starting from version 3.18.0-2.0 the wrapper requires Java 22 and the Java FFM API (which is still in preview).
Older versions of the wrapper still work with Java 11 or later, but they use JNI with same version of FreeImage.


## License

Expand Down Expand Up @@ -54,19 +57,19 @@ If you are using Maven, add one of the following dependencies in your POM:
<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4Java.macos</artifactId>
<version>3.18.0-2.1</version>
<version>3.18.0-2.2</version>
</dependency>

<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4Java.linux</artifactId>
<version>3.18.0-2.1</version>
<version>3.18.0-2.2</version>
</dependency>

<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4Java.windows</artifactId>
<version>3.18.0-2.1</version>
<version>3.18.0-2.2</version>
</dependency>

Also, add one of the following to download the native library:
Expand Down Expand Up @@ -226,25 +229,25 @@ Compile and package the JARs:

The artifacts will be created in the target directory of each module:

freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.1.jar
freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.1-x86_64.jar
freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.2.jar
freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.2-x86_64.jar

freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.1.jar
freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.1-x86_64.jar
freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.2.jar
freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.2-x86_64.jar

freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.1.jar
freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.1-x86_64.jar
freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.2.jar
freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.2-x86_64.jar

List the content of the JAR files:

unzip -t freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.1.jar
unzip -t freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.1-x86_64.jar
unzip -t freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.2.jar
unzip -t freeimage4Java-macos/target/com.nextbreakpoint.freeimage4Java.macos-3.18.0-2.2-x86_64.jar

unzip -t freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.1.jar
unzip -t freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.1-x86_64.jar
unzip -t freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.2.jar
unzip -t freeimage4Java-linux/target/com.nextbreakpoint.freeimage4Java.linux-3.18.0-2.2-x86_64.jar

unzip -t freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.1.jar
unzip -t freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.1-x86_64.jar
unzip -t freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.2.jar
unzip -t freeimage4Java-windows/target/com.nextbreakpoint.freeimage4Java.windows-3.18.0-2.2-x86_64.jar

Install the artifacts in your local Maven repository:

Expand Down Expand Up @@ -287,15 +290,11 @@ Generate the code for Windows (must be executed on Windows):

## Code examples

A simple example is provided for each supported system.

See POM files for details about how to download the native library and execute the code:

freeimage4Java-macos-examples/pom.xml
A simple example is provided in the module freeimage4Java-examples.

freeimage4Java-linux-examples/pom.xml
See the POM file for details about how to download the native library and execute the example:

freeimage4Java-windows-examples/pom.xml
freeimage4Java-examples/pom.xml


## References
Expand Down
165 changes: 165 additions & 0 deletions freeimage4java-examples/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java</artifactId>
<version>3.18.0-2.2</version>
</parent>
<artifactId>com.nextbreakpoint.freeimage4java.examples</artifactId>
<packaging>jar</packaging>
<name>FreeImage4Java Examples</name>
<description>FreeImage4Java provides a Java wrapper of FreeImage library</description>
<profiles>
<profile>
<id>macos</id>
<dependencies>
<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.macos</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-lib</id>
<phase>test-compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.macos</artifactId>
<classifier>x86_64</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
<includes>**/*.dylib</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>linux</id>
<dependencies>
<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.linux</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-lib</id>
<phase>test-compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.linux</artifactId>
<classifier>x86_64</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
<includes>**/*.so</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>windows</id>
<dependencies>
<dependency>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.windows</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-lib</id>
<phase>test-compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.nextbreakpoint</groupId>
<artifactId>com.nextbreakpoint.freeimage4java.windows</artifactId>
<classifier>x86_64</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
<includes>**/*.dll</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>--enable-preview</argument>
<argument>--enable-native-access=ALL-UNNAMED</argument>
<argument>-classpath</argument>
<classpath/>
<argument>-Djava.library.path=${project.build.directory}/lib</argument>
<argument>com.nextbreakpoint.freeimage4java.ConvertImageMain</argument>
<argument>sample.png</argument>
<argument>output.png</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.nextbreakpoint.freeimage4java.macos;
package com.nextbreakpoint.freeimage4java;

import java.lang.foreign.Arena;

import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FIF_PNG;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FreeImage_ConvertToGreyscale;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FreeImage_Initialise;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FreeImage_Load;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FreeImage_Save;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.FreeImage_Unload;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.PNG_DEFAULT;
import static com.nextbreakpoint.freeimage4java.macos.Libfreeimage.TRUE;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FIF_PNG;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FreeImage_ConvertToGreyscale;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FreeImage_Initialise;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FreeImage_Load;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FreeImage_Save;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.FreeImage_Unload;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.PNG_DEFAULT;
import static com.nextbreakpoint.freeimage4java.Libfreeimage.TRUE;
import static java.lang.foreign.MemorySegment.NULL;

class ConvertImageMain {
Expand All @@ -23,8 +23,8 @@ public static void main(String[] args) {

System.out.println("Converting image...");

System.out.println(STR."Source file \{sourceFileName}");
System.out.println(STR."Output file \{outputFileName}");
System.out.printf("Source file %s%n", sourceFileName);
System.out.printf("Output file %s%n", outputFileName);

try (var arena = Arena.ofConfined()) {
var pSourceBitmap = NULL;
Expand Down
Loading

0 comments on commit 4a780b2

Please sign in to comment.