From c8163742927586f4448ab6474e23897b8854b4e2 Mon Sep 17 00:00:00 2001 From: selfemp Date: Mon, 3 Apr 2023 20:07:27 +0200 Subject: [PATCH] Updates for JDK20/Javafx20 --- LibRawFX/pom.xml | 2 +- .../main/java/org/librawfx/LibrawImage.java | 21 +++++++++---------- .../src/main/java/org/librawfx/TestApp.java | 5 ++--- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/LibRawFX/pom.xml b/LibRawFX/pom.xml index a9a85d4..f7e18df 100644 --- a/LibRawFX/pom.xml +++ b/LibRawFX/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.librawfx LibRawFX - 1.8.4-SNAPSHOT + 1.8.4 LibRawFX This installs the native lib libraw as a JavaFX Image format provider similar to imageIO before on Swing diff --git a/LibRawFX/src/main/java/org/librawfx/LibrawImage.java b/LibRawFX/src/main/java/org/librawfx/LibrawImage.java index 67b7b31..f939b5b 100644 --- a/LibRawFX/src/main/java/org/librawfx/LibrawImage.java +++ b/LibRawFX/src/main/java/org/librawfx/LibrawImage.java @@ -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); @@ -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) { @@ -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); @@ -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); diff --git a/LibRawFX/src/main/java/org/librawfx/TestApp.java b/LibRawFX/src/main/java/org/librawfx/TestApp.java index 21f67a0..a02e20c 100644 --- a/LibRawFX/src/main/java/org/librawfx/TestApp.java +++ b/LibRawFX/src/main/java/org/librawfx/TestApp.java @@ -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; @@ -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; @@ -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()); @@ -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();