From 498d78073c24f25055a2dc4943cdd0a42f85702c Mon Sep 17 00:00:00 2001 From: John Hoford Date: Wed, 13 Feb 2013 15:52:31 -0800 Subject: get redeye working again --- .../gallery3d/filtershow/editors/EditorRedEye.java | 2 +- .../filtershow/filters/FilterRedEyeRepresentation.java | 11 +++++++++++ .../android/gallery3d/filtershow/filters/ImageFilter.java | 5 ++--- .../gallery3d/filtershow/filters/ImageFilterGeometry.java | 5 +++++ .../gallery3d/filtershow/filters/ImageFilterNegative.java | 5 +++++ .../gallery3d/filtershow/filters/ImageFilterRS.java | 2 +- .../gallery3d/filtershow/filters/ImageFilterRedEye.java | 15 ++++++++++++--- .../filtershow/filters/ImageFilterStraighten.java | 5 +++++ .../gallery3d/filtershow/filters/ImageFilterWBalance.java | 5 +++++ .../gallery3d/filtershow/imageshow/ImageRedEye.java | 2 +- 10 files changed, 48 insertions(+), 9 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java b/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java index 271f16535..c37102b37 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorRedEye.java @@ -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); } } diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java index 329f5204e..7779211df 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java @@ -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); } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index 256f5d671..7c5a75232 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -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); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java index 1380c528d..329ca81b9 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java @@ -66,6 +66,11 @@ public class ImageFilterGeometry extends ImageFilter { native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight, 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 diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java index 34cd052eb..841c5c913 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java @@ -24,6 +24,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(); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java index c741a4887..d5297904d 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java @@ -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; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java index 5f5314946..42587c06f 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java @@ -17,10 +17,13 @@ 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; @@ -61,13 +64,18 @@ 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; } } diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java index 92bde992d..a3bb6f980 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterStraighten.java @@ -52,6 +52,11 @@ public class ImageFilterStraighten extends ImageFilter { mZoomFactor = zoomFactor; } + @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 diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java index 7f21fea30..2f4852306 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterWBalance.java @@ -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 diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java index 2db9227b9..ba3dcdd1d 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java @@ -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(); -- cgit v1.2.3