diff --git a/LibRawFX/pom.xml b/LibRawFX/pom.xml
index dec0c07..d243c33 100644
--- a/LibRawFX/pom.xml
+++ b/LibRawFX/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.librawfx
LibRawFX
- 1.3
+ 1.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 967e8f2..1bb2ec7 100644
--- a/LibRawFX/src/main/java/org/librawfx/LibrawImage.java
+++ b/LibRawFX/src/main/java/org/librawfx/LibrawImage.java
@@ -8,7 +8,11 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.LocalDateTime;
import java.util.HashMap;
+import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import jdk.incubator.foreign.CLinker;
@@ -38,6 +42,8 @@ public class LibrawImage {
private static String[] loadLibraryFromJar;
private static String operatingSystem;
private RAWImageLoader loader;
+ private String cameraModel;
+ private LocalDateTime shootingDateTime;
public LibrawImage(String imageFile) {
this.imageFileURL = imageFile;
@@ -101,7 +107,7 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
} else {
libraries = org.libraw.linuxosx.RuntimeHelper.libraries(loadLibraryFromJar);
org.libraw.linuxosx.RuntimeHelper.setLibraryLookups(libraries);
- }
+ }
try (var scope = NativeScope.unboundedScope()) {
if (operatingSystem.contains("WIN")) {
@@ -116,14 +122,24 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
//libraw_output_params_t.output_color$set(params$slice, 0);
MemorySegment inputStreamBytes = MemorySegment.ofArray(sourceFileAsByteArray);
- MemorySegment allocateNative = scope.allocateArray(C_CHAR, sourceFileAsByteArray);
+ MemorySegment allocateNative = scope.allocateArray(C_CHAR, sourceFileAsByteArray);
int k = org.libraw.win.libraw_h.libraw_open_buffer(iprc, allocateNative, inputStreamBytes.byteSize());
if (k > 0) {
Logger.getLogger(LibrawImage.class.getName()).log(Level.SEVERE, null, "Cannot open stream, return value was: " + k);
throw new IOException("Cannot open file stream!");
}
-
+
org.libraw.win.libraw_h.libraw_unpack(iprc);
+
+ MemoryAddress iParams = org.libraw.win.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.win.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment modelSlice = org.libraw.win.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ cameraModel = new String(modelSlice.toByteArray(), StandardCharsets.US_ASCII);
+ MemoryAddress image_other_data = org.libraw.win.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.win.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ long timestamp = org.libraw.win.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ shootingDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), TimeZone.getDefault().toZoneId());
+
org.libraw.win.libraw_h.libraw_dcraw_process(iprc);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
@@ -147,7 +163,7 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
try {
bo.write(line);
} catch (IOException ex) {
- Logger.getLogger(LibrawImage.class.getName()).log(Level.SEVERE, "Cannot retrieve image from native memory", ex);
+ Logger.getLogger(LibrawImage.class.getName()).log(Level.SEVERE, "Cannot retrieve image from native memory", ex);
return null;
}
}
@@ -182,6 +198,16 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
}
org.libraw.linuxosx.libraw_h.libraw_unpack(iprc);
+
+ MemoryAddress iParams = org.libraw.linuxosx.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.linuxosx.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment modelSlice = org.libraw.linuxosx.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ cameraModel = new String(modelSlice.toByteArray(), StandardCharsets.US_ASCII);
+ MemoryAddress image_other_data = org.libraw.linuxosx.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.linuxosx.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ long timestamp = org.libraw.linuxosx.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ shootingDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), TimeZone.getDefault().toZoneId());
+
org.libraw.linuxosx.libraw_h.libraw_dcraw_process(iprc);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
@@ -205,8 +231,7 @@ public byte[] readPixelDataFromStream(byte[] sourceFileAsByteArray) throws IOExc
try {
bo.write(line);
} catch (IOException ex) {
- Logger.getLogger(LibrawImage.class.getName()).log(Level.SEVERE, "Cannot retrieve image from native memory and write into byte array!", ex);
- System.out.println("Exception " + ex.getMessage());
+ Logger.getLogger(LibrawImage.class.getName()).log(Level.SEVERE, "Cannot retrieve image from native memory and write into byte array!", ex);
return null;
}
}
@@ -270,6 +295,16 @@ public synchronized int[] readPixelData() throws IOException {
}
org.libraw.win.libraw_h.libraw_unpack(iprc);
+
+ MemoryAddress iParams = org.libraw.win.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.win.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment modelSlice = org.libraw.win.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ cameraModel = new String(modelSlice.toByteArray(), StandardCharsets.UTF_8);
+ MemoryAddress image_other_data = org.libraw.win.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.win.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ long timestamp = org.libraw.win.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ shootingDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), TimeZone.getDefault().toZoneId());
+
org.libraw.win.libraw_h.libraw_dcraw_process(iprc);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
@@ -326,6 +361,16 @@ public synchronized int[] readPixelData() throws IOException {
}
org.libraw.linuxosx.libraw_h.libraw_unpack(iprc);
+
+ MemoryAddress iParams = org.libraw.linuxosx.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.linuxosx.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment modelSlice = org.libraw.linuxosx.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ cameraModel = new String(modelSlice.toByteArray(), StandardCharsets.UTF_8);
+ MemoryAddress image_other_data = org.libraw.linuxosx.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.linuxosx.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ long timestamp = org.libraw.linuxosx.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ shootingDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timestamp), TimeZone.getDefault().toZoneId());
+
org.libraw.linuxosx.libraw_h.libraw_dcraw_process(iprc);
ByteArrayOutputStream bo = new ByteArrayOutputStream();
@@ -384,6 +429,12 @@ private synchronized int[] convertToINT(byte[] rawBytes) {
return raw;
}
+ /**
+ * Retrievs for the given file in the constructor the metadata
+ * Important: The timestamps are in EpocheInSeconds and not milliseconds
+ * @return Hashmap of all meta data
+ * @throws IOException
+ */
public HashMap getMetaData() throws IOException {
if (imageFileURL == null) {
Logger.getLogger(LibrawImage.class.getName()).log(Level.FINEST, null, "imageFileURL == null! " + imageFileURL);
@@ -418,14 +469,31 @@ public HashMap getMetaData() throws IOException {
org.libraw.win.libraw_h.libraw_dcraw_process(iprc);
- MemorySegment iParams = org.libraw.win.libraw_h.libraw_iparams_t.ofAddressRestricted(iprc);
- MemorySegment make$slice = org.libraw.win.libraw_h.libraw_iparams_t.make$slice(iParams);
-
- MemorySegment lens$slice = org.libraw.win.libraw_h.libraw_data_t.lens$slice(datasegment);
- org.libraw.win.libraw_h.libraw_lensinfo_t.FocalLengthIn35mmFormat$get(lens$slice);
+ MemoryAddress iParams = org.libraw.win.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.win.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment make$slice = org.libraw.win.libraw_h.libraw_iparams_t.make$slice(iParamsRestricted);
+ retMap.put("CameraMaker", new String(make$slice.toByteArray(), StandardCharsets.UTF_8));
+ MemorySegment model$slice = org.libraw.win.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ retMap.put("CameraModel", new String(model$slice.toByteArray(), StandardCharsets.UTF_8));
+ MemoryAddress xmpdata$get = org.libraw.win.libraw_h.libraw_iparams_t.xmpdata$get(iParamsRestricted);
+ int xmplen$get = org.libraw.win.libraw_h.libraw_iparams_t.xmplen$get(iParamsRestricted);
+ if (xmplen$get != 0) {
+ MemorySegment asSegmentRestricted = xmpdata$get.asSegmentRestricted(xmplen$get);
+ retMap.put("XMP", new String(asSegmentRestricted.toByteArray(), StandardCharsets.UTF_8));
+ }
- MemorySegment color$slice = org.libraw.win.libraw_h.libraw_data_t.color$slice(datasegment);
- int ExifColorSpace$get = org.libraw.win.libraw_h.libraw_colordata_t.ExifColorSpace$get(color$slice);
+ MemoryAddress image_other_data = org.libraw.win.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.win.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ float aperture = org.libraw.win.libraw_h.libraw_imgother_t.aperture$get(imageOtherRestricted);
+ float focal_len = org.libraw.win.libraw_h.libraw_imgother_t.focal_len$get(imageOtherRestricted);
+ float o_speed = org.libraw.win.libraw_h.libraw_imgother_t.iso_speed$get(imageOtherRestricted);
+ float shutter = org.libraw.win.libraw_h.libraw_imgother_t.shutter$get(imageOtherRestricted);
+ long timestamp = org.libraw.win.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ retMap.put("aperture", "" + aperture);
+ retMap.put("focal_len", "" + focal_len);
+ retMap.put("o_speed", "" + o_speed);
+ retMap.put("shutter", "" + shutter);
+ retMap.put("timestamp", "" + timestamp);
MemorySegment shootingInfo$slice = org.libraw.win.libraw_h.libraw_data_t.shootinginfo$slice(datasegment);
short afPoint = org.libraw.win.libraw_h.libraw_shootinginfo_t.AFPoint$get(shootingInfo$slice);
@@ -436,17 +504,9 @@ public HashMap getMetaData() throws IOException {
short imageStabiMode = org.libraw.win.libraw_h.libraw_shootinginfo_t.ImageStabilization$get(shootingInfo$slice);
short medteringMode = org.libraw.win.libraw_h.libraw_shootinginfo_t.MeteringMode$get(shootingInfo$slice);
- MemorySegment image_other_data = org.libraw.win.libraw_h.libraw_imgother_t.ofAddressRestricted(iprc);
- float aperture = org.libraw.win.libraw_h.libraw_imgother_t.aperture$get(image_other_data);
- float focal_len = org.libraw.win.libraw_h.libraw_imgother_t.focal_len$get(image_other_data);
- float o_speed = org.libraw.win.libraw_h.libraw_imgother_t.iso_speed$get(image_other_data);
- float shutter = org.libraw.win.libraw_h.libraw_imgother_t.shutter$get(image_other_data);
- long timestamp = org.libraw.win.libraw_h.libraw_imgother_t.timestamp$get(image_other_data);
-
MemorySegment errorCode = scope.allocate(C_INT.byteSize());
MemoryAddress mem_image_adr = org.libraw.win.libraw_h.libraw_dcraw_make_mem_image(iprc, errorCode.address());
MemorySegment imageMemSegment = org.libraw.win.libraw_h.libraw_processed_image_t.ofAddressRestricted(mem_image_adr);
- MemorySegment data$slice = org.libraw.win.libraw_h.libraw_processed_image_t.data$slice(imageMemSegment);
imageWidth = org.libraw.win.libraw_h.libraw_processed_image_t.width$get(imageMemSegment);
imageHeight = org.libraw.win.libraw_h.libraw_processed_image_t.height$get(imageMemSegment);
imageBits = org.libraw.win.libraw_h.libraw_processed_image_t.bits$get(imageMemSegment);
@@ -462,11 +522,6 @@ public HashMap getMetaData() throws IOException {
retMap.put("imageHeight", "" + imageHeight);
retMap.put("imageBits", "" + imageBits);
retMap.put("imageColors", "" + imageColors);
- retMap.put("aperture", "" + aperture);
- retMap.put("focal_len", "" + focal_len);
- retMap.put("o_speed", "" + o_speed);
- retMap.put("shutter", "" + shutter);
- retMap.put("timestamp", "" + timestamp);
return retMap;
} else {
@@ -485,14 +540,31 @@ public HashMap getMetaData() throws IOException {
org.libraw.linuxosx.libraw_h.libraw_dcraw_process(iprc);
- MemorySegment iParams = org.libraw.linuxosx.libraw_h.libraw_iparams_t.ofAddressRestricted(iprc);
- MemorySegment make$slice = org.libraw.linuxosx.libraw_h.libraw_iparams_t.make$slice(iParams);
-
- MemorySegment lens$slice = org.libraw.linuxosx.libraw_h.libraw_data_t.lens$slice(datasegment);
- org.libraw.linuxosx.libraw_h.libraw_lensinfo_t.FocalLengthIn35mmFormat$get(lens$slice);
+ MemoryAddress iParams = org.libraw.linuxosx.libraw_h.libraw_get_iparams(iprc);
+ MemorySegment iParamsRestricted = org.libraw.linuxosx.libraw_h.libraw_iparams_t.ofAddressRestricted(iParams);
+ MemorySegment make$slice = org.libraw.linuxosx.libraw_h.libraw_iparams_t.make$slice(iParamsRestricted);
+ retMap.put("CameraMaker", new String(make$slice.toByteArray(), StandardCharsets.UTF_8));
+ MemorySegment model$slice = org.libraw.linuxosx.libraw_h.libraw_iparams_t.model$slice(iParamsRestricted);
+ retMap.put("CameraModel", new String(model$slice.toByteArray(), StandardCharsets.UTF_8));
+ MemoryAddress xmpdata$get = org.libraw.linuxosx.libraw_h.libraw_iparams_t.xmpdata$get(iParamsRestricted);
+ int xmplen$get = org.libraw.linuxosx.libraw_h.libraw_iparams_t.xmplen$get(iParamsRestricted);
+ if (xmplen$get != 0) {
+ MemorySegment asSegmentRestricted = xmpdata$get.asSegmentRestricted(xmplen$get);
+ retMap.put("XMP", new String(asSegmentRestricted.toByteArray(), StandardCharsets.UTF_8));
+ }
- MemorySegment color$slice = org.libraw.linuxosx.libraw_h.libraw_data_t.color$slice(datasegment);
- int ExifColorSpace$get = org.libraw.linuxosx.libraw_h.libraw_colordata_t.ExifColorSpace$get(color$slice);
+ MemoryAddress image_other_data = org.libraw.linuxosx.libraw_h.libraw_get_imgother(iprc);
+ MemorySegment imageOtherRestricted = org.libraw.linuxosx.libraw_h.libraw_imgother_t.ofAddressRestricted(image_other_data);
+ float aperture = org.libraw.linuxosx.libraw_h.libraw_imgother_t.aperture$get(imageOtherRestricted);
+ float focal_len = org.libraw.linuxosx.libraw_h.libraw_imgother_t.focal_len$get(imageOtherRestricted);
+ float o_speed = org.libraw.linuxosx.libraw_h.libraw_imgother_t.iso_speed$get(imageOtherRestricted);
+ float shutter = org.libraw.linuxosx.libraw_h.libraw_imgother_t.shutter$get(imageOtherRestricted);
+ long timestamp = org.libraw.linuxosx.libraw_h.libraw_imgother_t.timestamp$get(imageOtherRestricted);
+ retMap.put("aperture", "" + aperture);
+ retMap.put("focal_len", "" + focal_len);
+ retMap.put("o_speed", "" + o_speed);
+ retMap.put("shutter", "" + shutter);
+ retMap.put("timestamp", "" + timestamp);
MemorySegment shootingInfo$slice = org.libraw.linuxosx.libraw_h.libraw_data_t.shootinginfo$slice(datasegment);
short afPoint = org.libraw.linuxosx.libraw_h.libraw_shootinginfo_t.AFPoint$get(shootingInfo$slice);
@@ -503,13 +575,6 @@ public HashMap getMetaData() throws IOException {
short imageStabiMode = org.libraw.linuxosx.libraw_h.libraw_shootinginfo_t.ImageStabilization$get(shootingInfo$slice);
short medteringMode = org.libraw.linuxosx.libraw_h.libraw_shootinginfo_t.MeteringMode$get(shootingInfo$slice);
- MemorySegment image_other_data = org.libraw.linuxosx.libraw_h.libraw_imgother_t.ofAddressRestricted(iprc);
- float aperture = org.libraw.linuxosx.libraw_h.libraw_imgother_t.aperture$get(image_other_data);
- float focal_len = org.libraw.linuxosx.libraw_h.libraw_imgother_t.focal_len$get(image_other_data);
- float o_speed = org.libraw.linuxosx.libraw_h.libraw_imgother_t.iso_speed$get(image_other_data);
- float shutter = org.libraw.linuxosx.libraw_h.libraw_imgother_t.shutter$get(image_other_data);
- long timestamp = org.libraw.linuxosx.libraw_h.libraw_imgother_t.timestamp$get(image_other_data);
-
MemorySegment errorCode = scope.allocate(C_INT.byteSize());
MemoryAddress mem_image_adr = org.libraw.linuxosx.libraw_h.libraw_dcraw_make_mem_image(iprc, errorCode.address());
MemorySegment imageMemSegment = org.libraw.linuxosx.libraw_h.libraw_processed_image_t.ofAddressRestricted(mem_image_adr);
@@ -607,6 +672,16 @@ public int getNumBands() {
return imageColors * (imageBits / 8);
}
+ public String getCameraModel() {
+ return cameraModel;
+ }
+
+ public LocalDateTime getShootingDateTime() {
+ return shootingDateTime;
+ }
+
+
+
/**
* String representation of the image
*
diff --git a/LibRawFX/src/main/java/org/librawfx/RAWImageLoader.java b/LibRawFX/src/main/java/org/librawfx/RAWImageLoader.java
index 559beed..88dc1bc 100644
--- a/LibRawFX/src/main/java/org/librawfx/RAWImageLoader.java
+++ b/LibRawFX/src/main/java/org/librawfx/RAWImageLoader.java
@@ -56,10 +56,10 @@ protected void updateImageMetadata(ImageMetadata im) {
}
@Override
- protected void updateImageProgress(float f) {
+ protected void updateImageProgress(float f) {
super.updateImageProgress(f);
}
-
+
@Override
protected void emitWarning(String string) {
super.emitWarning(string); //To change body of generated methods, choose Tools | Templates.
@@ -76,18 +76,22 @@ public ImageFrame load(int imageIndex, int width, int height, boolean preserveAs
ByteBuffer imageData = null;
short rawImageWidth = -1;
short rawImageHeight = -1;
- int rawImageStride = 0;
- double ratio = 0;
- try {
+ int rawImageStride = 0;
+ try {
updateImageProgress(0);
- imageData = getImageData(libraw);
+ long start = System.currentTimeMillis();
+ imageData = getImageData(libraw);
+ double diff = (System.currentTimeMillis() - start) / 1000;
+ Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINE, null, "Raw loading took: " + diff + "s");
+ updateImageProgress(lastPercentDone+1);
rawImageWidth = libraw.getImageWidth();
Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINEST, null, "rawImageWidth " + rawImageWidth);
rawImageHeight = libraw.getImageHeight();
- rawImageStride = libraw.getStride();
- int[] widthHeight = ImageTools.computeDimensions(rawImageWidth, rawImageHeight, width, height, preserveAspectRatio);
+ rawImageStride = libraw.getStride();
+ int[] widthHeight = ImageTools.computeDimensions(rawImageWidth, rawImageHeight, width, height, preserveAspectRatio);
width = widthHeight[0];
- height = widthHeight[1];
+ height = widthHeight[1];
+ updateImageProgress(lastPercentDone+1);
} catch (IOException e) {
Logger.getLogger(RAWImageLoader.class.getName()).log(Level.SEVERE, null, e);
throw e;
@@ -109,18 +113,20 @@ public ImageFrame load(int imageIndex, int width, int height, boolean preserveAs
ImageMetadata md = new ImageMetadata(null, true,
null, null, null, null, null,
- width, height, null, null, null);
-
+ width, height, null, null, null);
updateImageMetadata(md);
+ updateImageProgress(lastPercentDone+1);
- if (rawImageWidth != width || rawImageHeight != height) {
+ if (rawImageWidth != width || rawImageHeight != height) {
imageData = ImageTools.scaleImage(imageData, rawImageWidth, rawImageHeight, libraw.getNumBands(), width, height, smooth);
}
+ updateImageProgress(lastPercentDone+1);
rawImageStride = width * libraw.getNumBands();
- Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINEST, null, "Creating image frame...");
+ Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINEST, null, "Creating image frame...");
ImageFrame createImageFrame = new FixedPixelDensityImageFrame(ImageStorage.ImageType.RGB, imageData, width,
height, rawImageStride, null, getPixelScale(), md);
- Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINEST, null, "Creating image frame...finished");
+ Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINEST, null, "Creating image frame...finished");
+ updateImageProgress(100f);
return createImageFrame;
}
@@ -152,13 +158,15 @@ private synchronized ByteBuffer getImageData(LibrawImage libraw) throws IOExcept
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] datab = new byte[1024];
+ long reading = System.currentTimeMillis();
while ((nRead = input.read(datab, 0, datab.length)) != -1) {
buffer.write(datab, 0, nRead);
}
buffer.flush();
byte[] targetArray = buffer.toByteArray();
byte[] raw = libraw.readPixelDataFromStream(targetArray);
- updateImageProgress(100f);
+ double diff = (System.currentTimeMillis() - reading) / 1000;
+ Logger.getLogger(RAWImageLoader.class.getName()).log(Level.FINE, null, "Raw convert took: " + diff + "s");
return ByteBuffer.wrap(raw);
}
@@ -170,7 +178,7 @@ private synchronized ByteBuffer getImageData(LibrawImage libraw) throws IOExcept
*/
public void updateImageProgress(int outLinesDecoded, int outHeight) {
float res = 100.0F * outLinesDecoded / outHeight;
- updateImageProgress(100.0F * outLinesDecoded / outHeight);
+ updateImageProgress(res);
}
private static class Lock {
diff --git a/LibRawFX/src/main/java/org/librawfx/TestApp.java b/LibRawFX/src/main/java/org/librawfx/TestApp.java
index c76761c..f92cd6e 100644
--- a/LibRawFX/src/main/java/org/librawfx/TestApp.java
+++ b/LibRawFX/src/main/java/org/librawfx/TestApp.java
@@ -4,14 +4,22 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.FileHandler;
+import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
+import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
+import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelFormat;
@@ -27,7 +35,7 @@
public class TestApp extends Application {
@Override
- public void start(Stage stage) throws FileNotFoundException, IOException {
+ public void start(Stage stage) throws FileNotFoundException, IOException {
RAWImageLoaderFactory.install();
Parameters parameters = getParameters();
@@ -52,11 +60,6 @@ private void loadImagesByStream(VBox stack, String file, String file2, String fi
//ind.progressProperty().bind(img.progressProperty());
Button btn = new Button("Refresh");
stack.getChildren().add(btn);
- try {
- new LibrawImage(file).getMetaData();
- } catch (IOException ex) {
- Logger.getLogger(TestApp.class.getName()).log(Level.SEVERE, null, ex);
- }
loadImages(stack, initialFile, initialFile2, initialFile3);
btn.setOnAction((t) -> {
@@ -82,24 +85,37 @@ private void loadImages(VBox stack, File initialFile, File initialFile2, File in
ProgressIndicator ind = new ProgressIndicator();
ProgressIndicator ind2 = new ProgressIndicator();
ProgressIndicator ind3 = new ProgressIndicator();
- stack.getChildren().add(ind);
- stack.getChildren().add(ind2);
- stack.getChildren().add(ind3);
+ stack.getChildren().add(ind);
+ stack.getChildren().add(ind2);
+ stack.getChildren().add(ind3);
Image img = new Image(initialFile.toURI().toURL().toString(), size, size, true, false, backgroundLoading);
img.progressProperty().addListener((ov, t, t1) -> {
- if (t1.doubleValue() == 1.0) {
+ if (t1.doubleValue() == 1.0) {
stack.getChildren().remove(ind);
stack.getChildren().add(view);
+ try {
+ HashMap metaData = new LibrawImage(initialFile.getAbsolutePath()).getMetaData();
+ ScrollPane sc = new ScrollPane();
+ VBox vb = new VBox();
+ metaData.entrySet().forEach((entry) -> {
+ Label l = new Label(entry.getKey() + " " + entry.getValue());
+ vb.getChildren().add(l);
+ });
+ sc.setContent(vb);
+ stack.getChildren().add(sc);
+ } catch (IOException ex) {
+ Logger.getLogger(TestApp.class.getName()).log(Level.SEVERE, null, ex);
+ }
if (img.getException() != null) {
System.out.println("Exception for: " + img.getUrl());
img.getException().printStackTrace();
}
}
- });
+ });
ind.progressProperty().bind(img.progressProperty());
Image img2 = new Image(initialFile2.toURI().toURL().toString(), size, size, true, false, backgroundLoading);
img2.progressProperty().addListener((ov, t, t1) -> {
- if (t1.doubleValue() == 1.0) {
+ if (t1.doubleValue() == 1.0) {
stack.getChildren().remove(ind2);
stack.getChildren().add(view2);
if (img2.getException() != null) {
@@ -107,11 +123,11 @@ private void loadImages(VBox stack, File initialFile, File initialFile2, File in
img2.getException().printStackTrace();
}
}
- });
+ });
ind2.progressProperty().bind(img2.progressProperty());
Image img3 = new Image(initialFile3.toURI().toURL().toString(), size, size, true, false, backgroundLoading);
img3.progressProperty().addListener((ov, t, t1) -> {
- if (t1.doubleValue() == 1.0) {
+ if (t1.doubleValue() == 1.0) {
stack.getChildren().remove(ind3);
stack.getChildren().add(view3);
if (img3.getException() != null) {
@@ -119,7 +135,7 @@ private void loadImages(VBox stack, File initialFile, File initialFile2, File in
img3.getException().printStackTrace();
}
}
- });
+ });
ind3.progressProperty().bind(img3.progressProperty());
view.setImage(img);
view.setFitHeight(size);
@@ -160,6 +176,11 @@ public static void main(String[] args) {
args[2] = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "ressources" + File.separator + "sample1.cr2";
args[1] = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "ressources" + File.separator + "RAW_SIGMA_DP2_MERRILL.X3F";
args[0] = System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "ressources" + File.separator + "RAW-ADOBE_DNG_Sample.dng";
+ Logger logger = Logger.getLogger("");
+ Handler handler = new ConsoleHandler();
+ logger.addHandler(handler);
+ logger.setLevel(Level.ALL);
+ handler.setFormatter(new SimpleFormatter());
launch(args);
}