changeset 1589:6892f39c1fdb

Merge with 107159069baf23478295ede170c22d7b88bc18b2
author robcast
date Wed, 08 Feb 2017 14:52:46 +0100
parents e9ad60c4fb0c (diff) 107159069baf (current diff)
children bd71cb53e1a3
files
diffstat 2 files changed, 36 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/common/src/main/java/digilib/conf/DigilibConfiguration.java	Sun Dec 04 19:33:50 2016 +0100
+++ b/common/src/main/java/digilib/conf/DigilibConfiguration.java	Wed Feb 08 14:52:46 2017 +0100
@@ -57,7 +57,7 @@
 
     /** digilib version */
     public static String getClassVersion() {
-        return "2.4.0a";
+        return "2.4.1a";
     }
 
     /* non-static getVersion for Java inheritance */
--- a/common/src/main/java/digilib/image/ImageJobDescription.java	Sun Dec 04 19:33:50 2016 +0100
+++ b/common/src/main/java/digilib/image/ImageJobDescription.java	Wed Feb 08 14:52:46 2017 +0100
@@ -184,7 +184,7 @@
 
     /**
      * Creates new ImageJobDescription by merging Parameters from a
-     * DigilibRequest and adding an ImageSEt.
+     * DigilibRequest and adding an ImageSet.
      * 
      * @param dlReq
      * @param imgs
@@ -322,21 +322,50 @@
         } else if (scaleY == 0) {
             // dh undefined
             scaleY = scaleX;
+        } else if (hasOption("crop")) {
+            // use the bigger factor to get fill-the-box
+            if (scaleX > scaleY) {
+                scaleY = scaleX;
+                // crop mode uses whole destination rect
+                long croppedAreaHeight = (long) (getDh() / scaleY);
+                if (areaHeight > croppedAreaHeight) {
+                	// center cropped area
+                	areaY += (areaHeight - croppedAreaHeight) / 2;
+                }
+                areaHeight = croppedAreaHeight;
+            } else {
+                scaleX = scaleY;
+                // crop mode uses whole destination rect
+                long croppedAreaWidth = (long) (getDw() / scaleX);
+                if (areaWidth > croppedAreaWidth) {
+                	// center cropped area
+                	areaX += (areaWidth - croppedAreaWidth) / 2;
+                }
+                areaWidth = croppedAreaWidth;
+            }
         } else {
             // use the smaller factor to get fit-in-box
             if (scaleX > scaleY) {
                 scaleX = scaleY;
                 if (hasOption("fill")) {
                     // fill mode uses whole destination rect
-                    // TODO: should we center, clip or shift the area?
-                    areaWidth = (long) (getDw() / scaleX);
+                    long filledAreaWidth = (long) (getDw() / scaleX);
+                    if (filledAreaWidth > areaWidth) {
+                    	// center filled area
+                    	areaX -= (filledAreaWidth - areaWidth) / 2;
+                    }
+                    areaWidth = filledAreaWidth;
                 }
             } else {
                 scaleY = scaleX;
                 if (hasOption("fill")) {
                     // fill mode uses whole destination rect
-                    // TODO: should we center, clip or shift the area?
-                    areaHeight = (long) (getDh() / scaleY);
+                    long filledAreaHeight = (long) (getDh() / scaleY);
+                    if (filledAreaHeight > areaHeight) {
+                    	// center filled area
+                    	areaY -= (filledAreaHeight - areaHeight) / 2;
+                    }
+                    areaHeight = filledAreaHeight;
                 }
             }
         }
@@ -691,7 +720,7 @@
     }
 
     /**
-     * Do not scale, just crop.
+     * Do not scale, just crop original resolution.
      * 
      * @return
      */