OSDN Git Service

G+ crop overlay shadows. Aspect ratios.
authorRuben Brunk <rubenbrunk@google.com>
Fri, 12 Apr 2013 01:01:25 +0000 (18:01 -0700)
committerRuben Brunk <rubenbrunk@google.com>
Fri, 12 Apr 2013 02:39:18 +0000 (19:39 -0700)
Bug: 8597538

Change-Id: I9a7225a125bef7e11d6bf420bf1fa55e7f22c909

src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
src/com/android/gallery3d/filtershow/crop/CropMath.java
src/com/android/gallery3d/filtershow/crop/CropObject.java

index 749ba0e..483cb63 100644 (file)
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package com.android.gallery3d.filtershow.crop;
 
 import android.graphics.Canvas;
@@ -91,6 +92,15 @@ public abstract class CropDrawingUtils {
         }
     }
 
+    public static void drawShadows(Canvas canvas, Paint p, RectF innerBounds, RectF outerBounds) {
+        canvas.drawRect(outerBounds.left, outerBounds.top, innerBounds.right, innerBounds.top, p);
+        canvas.drawRect(innerBounds.right, outerBounds.top, outerBounds.right, innerBounds.bottom,
+                p);
+        canvas.drawRect(innerBounds.left, innerBounds.bottom, outerBounds.right,
+                outerBounds.bottom, p);
+        canvas.drawRect(outerBounds.left, innerBounds.top, innerBounds.left, outerBounds.bottom, p);
+    }
+
     public static Matrix getBitmapToDisplayMatrix(RectF imageBounds, RectF displayBounds) {
         Matrix m = new Matrix();
         CropDrawingUtils.setBitmapToDisplayMatrix(m, imageBounds, displayBounds);
index 5914f1c..52b11a5 100644 (file)
@@ -194,9 +194,9 @@ public class CropMath {
         float finalW = origW;
         float finalH = origH;
         if (origA < a) {
-            finalH = origH / a;
+            finalH = origW / a;
         } else {
-            finalW = origW * a;
+            finalW = origH * a;
         }
         float centX = r.centerX();
         float centY = r.centerY();
index 08cf158..7999b48 100644 (file)
@@ -166,7 +166,7 @@ public class CropObject {
             throw new IllegalArgumentException("bad edge selected");
             // return false;
         }
-        if ((mFixAspectRatio && !checkCorner(edge)) && !checkBlock(edge)) {
+        if ((mFixAspectRatio && !checkCorner(edge)) && !checkBlock(edge) && edge != MOVE_NONE) {
             // temporary
             throw new IllegalArgumentException("bad corner selected");
             // return false;