Skip to content

Commit

Permalink
Updates for JDK20/Javafx20
Browse files Browse the repository at this point in the history
  • Loading branch information
selfemp committed Apr 3, 2023
1 parent 7ba96e9 commit c816374
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LibRawFX/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.librawfx</groupId>
<artifactId>LibRawFX</artifactId>
<version>1.8.4-SNAPSHOT</version>
<version>1.8.4</version>

<name>LibRawFX</name>
<description>This installs the native lib libraw as a JavaFX Image format provider similar to imageIO before on Swing</description>
Expand Down
21 changes: 10 additions & 11 deletions LibRawFX/src/main/java/org/librawfx/LibrawImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
byte[] line = new byte[stride];
for (var i = 0; i < imageHeight; i++) {
loader.updateImageProgress(i, imageHeight);
MemorySegment addOffset = data$slice.getAtIndex(ValueLayout.ADDRESS, stride * i);
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(addOffset.address(), stride, scope.scope());
long offSetAdr=data$slice.address()+stride * i;
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(offSetAdr, stride, scope.scope());
line = asSegmentRestricted.toArray(ValueLayout.JAVA_BYTE);
try {
bo.write(line);
Expand Down Expand Up @@ -230,11 +230,10 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
Logger.getLogger(LibrawImage.class.getName()).log(Level.FINEST, null, "Start reading image from native memory...");
byte[] line = new byte[stride];
for (var i = 0; i < imageHeight; i++) {
loader.updateImageProgress(i, imageHeight);
//MemorySegment addOffset = data$slice.get(ValueLayout.ADDRESS, stride * i);
long offs=data$slice.address()+stride * i;
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(offs, stride, scope.scope());
line = asSegmentRestricted.toArray(ValueLayout.JAVA_BYTE);
loader.updateImageProgress(i, imageHeight);
long offSetAdr=data$slice.address()+stride * i;
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(offSetAdr, stride, scope.scope());
line = asSegmentRestricted.toArray(ValueLayout.JAVA_BYTE);
try {
bo.write(line);
} catch (IOException ex) {
Expand Down Expand Up @@ -321,8 +320,8 @@ public synchronized int[] readPixelData() throws IOException {
Logger.getLogger(LibrawImage.class.getName()).log(Level.FINEST, null, "Reading image from native memory...");
byte[] line = new byte[stride];
for (var i = 0; i < imageHeight; i++) {
MemorySegment addOffset = data$slice.getAtIndex(ValueLayout.ADDRESS, stride * i);
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(addOffset.address(), stride, scope.scope());
long offSetAdr=data$slice.address()+stride * i;
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(offSetAdr, stride, scope.scope());
line = asSegmentRestricted.toArray(ValueLayout.JAVA_BYTE);
try {
bo.write(line);
Expand Down Expand Up @@ -387,8 +386,8 @@ public synchronized int[] readPixelData() throws IOException {
Logger.getLogger(LibrawImage.class.getName()).log(Level.FINEST, null, "Reading image from native memory...");
byte[] line = new byte[stride];
for (var i = 0; i < imageHeight; i++) {
MemorySegment addOffset = data$slice.getAtIndex(ValueLayout.ADDRESS, stride * i);
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(addOffset.address(), stride, scope.scope());
long offSetAdr=data$slice.address()+stride * i;
MemorySegment asSegmentRestricted = MemorySegment.ofAddress(offSetAdr, stride, scope.scope());
line = asSegmentRestricted.toArray(ValueLayout.JAVA_BYTE);
try {
bo.write(line);
Expand Down
5 changes: 2 additions & 3 deletions LibRawFX/src/main/java/org/librawfx/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
Expand All @@ -25,7 +24,6 @@
import javafx.scene.image.PixelFormat;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
Expand Down Expand Up @@ -57,7 +55,7 @@ public void start(Stage stage) throws FileNotFoundException, IOException {
}

private void loadImagesByStream(VBox stack, String file, String file2, String file3) throws MalformedURLException {
File initialFile = new File(file);
File initialFile = new File(file);
File initialFile2 = new File(file2);
File initialFile3 = new File(file3);
//ind.progressProperty().bind(img.progressProperty());
Expand Down Expand Up @@ -203,6 +201,7 @@ private void loadImagesByFile(VBox stack, String file) throws IOException {
for (int i = 0; i < 1; i++) {
File initialFile = new File(file);
LibrawImage libraw = new LibrawImage(initialFile.getAbsolutePath(), new RawDecoderSettings());
System.out.println("CameraMaker "+libraw.getCameraMaker());
int[] raw = libraw.readPixelData();
WritableImage img = new WritableImage(libraw.getImageWidth(), libraw.getImageHeight());
PixelWriter pw = img.getPixelWriter();
Expand Down

0 comments on commit c816374

Please sign in to comment.