OSDN Git Service

get redeye working again
authorJohn Hoford <hoford@google.com>
Wed, 13 Feb 2013 23:52:31 +0000 (15:52 -0800)
committerJohn Hoford <hoford@google.com>
Thu, 14 Feb 2013 01:38:32 +0000 (17:38 -0800)
res/layout/filtershow_zoom_editor.xml
src/com/android/gallery3d/filtershow/editors/EditorRedEye.java
src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
src/com/android/gallery3d/filtershow/filters/ImageFilter.java
src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java
src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java
src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java

index edc52e8..3ef6f6b 100644 (file)
@@ -22,7 +22,7 @@
     android:layout_height="wrap_content"
     android:layout_weight="1" >
 
-    <com.android.gallery3d.filtershow.imageshow.ImageZoom
+    <com.android.gallery3d.filtershow.imageshow.ImageShow
         android:id="@+id/imageZoom"
         android:layout_width="match_parent"
         android:layout_height="wrap_content" />
index 271f165..c37102b 100644 (file)
@@ -51,10 +51,10 @@ public class EditorRedEye extends Editor {
     @Override
     public void reflectCurrentFilter() {
         super.reflectCurrentFilter();
-
         FilterRepresentation rep = getLocalRepresentation();
         if (rep != null && getLocalRepresentation() instanceof FilterRedEyeRepresentation) {
             FilterRedEyeRepresentation redEyeRep = (FilterRedEyeRepresentation) rep;
+
             mImageRedEyes.setRepresentation(redEyeRep);
         }
     }
index 329f520..7779211 100644 (file)
@@ -65,6 +65,17 @@ public class FilterRedEyeRepresentation extends FilterRepresentation {
         this.mCandidates.add(c);
     }
 
+    @Override
+    public void useParametersFrom(FilterRepresentation a) {
+        if (a instanceof FilterRedEyeRepresentation) {
+            FilterRedEyeRepresentation representation = (FilterRedEyeRepresentation) a;
+            mCandidates.clear();
+            for (RedEyeCandidate redEyeCandidate : representation.mCandidates) {
+                mCandidates.add(redEyeCandidate);
+            }
+        }
+    }
+
     public void removeCandidate(RedEyeCandidate c) {
         this.mCandidates.remove(c);
     }
index 256f5d6..7c5a752 100644 (file)
@@ -22,7 +22,7 @@ import com.android.gallery3d.R;
 import com.android.gallery3d.filtershow.editors.BasicEditor;
 import com.android.gallery3d.filtershow.presets.ImagePreset;
 
-public class ImageFilter implements Cloneable {
+public abstract class ImageFilter implements Cloneable {
 
     private ImagePreset mImagePreset;
 
@@ -58,8 +58,7 @@ public class ImageFilter implements Cloneable {
         mImagePreset = imagePreset;
     }
 
-    public void useRepresentation(FilterRepresentation representation) {
-    }
+    public abstract void useRepresentation(FilterRepresentation representation);
 
     native protected void nativeApplyGradientFilter(Bitmap bitmap, int w, int h,
             int[] redGradient, int[] greenGradient, int[] blueGradient);
index 1380c52..329ca81 100644 (file)
@@ -67,6 +67,11 @@ public class ImageFilterGeometry extends ImageFilter {
             Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
 
     @Override
+    public void useRepresentation(FilterRepresentation representation) {
+
+    }
+
+    @Override
     public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
         // TODO: implement bilinear or bicubic here... for now, just use
         // canvas to do a simple implementation...
index 34cd052..841c5c9 100644 (file)
@@ -25,6 +25,11 @@ public class ImageFilterNegative extends ImageFilter {
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
 
     @Override
+    public void useRepresentation(FilterRepresentation representation) {
+
+    }
+
+    @Override
     public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
         int w = bitmap.getWidth();
         int h = bitmap.getHeight();
index c741a48..d529790 100644 (file)
@@ -21,7 +21,7 @@ import android.graphics.Bitmap;
 import android.support.v8.renderscript.*;
 import android.util.Log;
 
-public class ImageFilterRS extends ImageFilter {
+public abstract class ImageFilterRS extends ImageFilter {
     private final String LOGTAG = "ImageFilterRS";
 
     private static RenderScript mRS = null;
index 5f53149..42587c0 100644 (file)
 package com.android.gallery3d.filtershow.filters;
 
 import android.graphics.Bitmap;
+import android.graphics.Canvas;
 import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
 import android.graphics.RectF;
+import android.util.Log;
 
-import com.android.gallery3d.R;
 import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
 
 import java.util.Vector;
@@ -62,12 +65,17 @@ public class ImageFilterRedEye extends ImageFilter {
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short[] matrix);
 
     @Override
+    public void useRepresentation(FilterRepresentation representation) {
+        FilterRedEyeRepresentation parameters = (FilterRedEyeRepresentation) representation;
+        mParameters = parameters;
+    }
+
+    @Override
     public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
         int w = bitmap.getWidth();
         int h = bitmap.getHeight();
         short[] rect = new short[4];
         int size = mParameters.getNumberOfCandidates();
-
         for (int i = 0; i < size; i++) {
             RectF r = new RectF(mParameters.getCandidate(i).mRect);
             GeometryMetadata geo = getImagePreset().mGeoData;
@@ -100,13 +108,14 @@ public class ImageFilterRedEye extends ImageFilter {
             if (r.bottom > h) {
                 r.bottom = h;
             }
+
             rect[0] = (short) r.left;
             rect[1] = (short) r.top;
             rect[2] = (short) r.width();
             rect[3] = (short) r.height();
+
             nativeApplyFilter(bitmap, w, h, rect);
         }
-
         return bitmap;
     }
 }
index 92bde99..a3bb6f9 100644 (file)
@@ -53,6 +53,11 @@ public class ImageFilterStraighten extends ImageFilter {
     }
 
     @Override
+    public void useRepresentation(FilterRepresentation representation) {
+
+    }
+
+    @Override
     public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
         // TODO: implement bilinear or bicubic here... for now, just use
         // canvas to do a simple implementation...
index 7f21fea..2f48523 100644 (file)
@@ -40,6 +40,11 @@ public class ImageFilterWBalance extends ImageFilter {
         return representation;
     }
 
+    @Override
+    public void useRepresentation(FilterRepresentation representation) {
+
+    }
+
     native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, int locX, int locY);
 
     @Override
index 2db9227..ba3dcdd 100644 (file)
@@ -9,6 +9,7 @@ import android.graphics.Paint;
 import android.graphics.Paint.Style;
 import android.graphics.RectF;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.MotionEvent;
 
 import com.android.gallery3d.filtershow.editors.EditorRedEye;
@@ -119,7 +120,6 @@ public class ImageRedEye extends ImageShow {
         Matrix originalRotateToScreen = geo.getOriginalToScreen(true,
                 mImageLoader.getOriginalBounds().width(),
                 mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
-
         if (mRedEyeRep != null) {
             for (RedEyeCandidate candidate : mRedEyeRep.getCandidates()) {
                 RectF rect = candidate.getRect();