diff options
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters')
8 files changed, 46 insertions, 7 deletions
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 @@ -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... 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 @@ -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(); 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; @@ -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; } } 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 @@ -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... 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 |