summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-02-14 23:40:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-02-14 23:40:25 +0000
commitc551fcd76cbbf0611f365bbe2b86c87c6226b348 (patch)
treeecb0a9ff8b94850c2506799c319ab56706d8287d /src
parentec2cebe4912bbb1a040b0bd52b250528671ef73d (diff)
parent7847563eaa8e039cd196a695485c322d81b1967e (diff)
downloadandroid_packages_apps_Snap-c551fcd76cbbf0611f365bbe2b86c87c6226b348.tar.gz
android_packages_apps_Snap-c551fcd76cbbf0611f365bbe2b86c87c6226b348.tar.bz2
android_packages_apps_Snap-c551fcd76cbbf0611f365bbe2b86c87c6226b348.zip
Merge "refactor to support many filter based on RedEye" into gb-ub-photos-bryce
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterPoint.java21
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java87
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java69
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java10
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java7
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java66
-rw-r--r--src/com/android/gallery3d/filtershow/filters/RedEyeCandidate.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java103
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java116
9 files changed, 287 insertions, 196 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterPoint.java b/src/com/android/gallery3d/filtershow/filters/FilterPoint.java
new file mode 100644
index 000000000..4520717a1
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterPoint.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+public interface FilterPoint {
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
new file mode 100644
index 000000000..fc01650ae
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/FilterPointRepresentation.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import java.util.Vector;
+
+public abstract class FilterPointRepresentation extends FilterRepresentation {
+ private static final String LOGTAG = "FilterPointRepresentation";
+ private Vector<FilterPoint> mCandidates = new Vector<FilterPoint>();
+
+ public FilterPointRepresentation(String type, int textid, int editorID) {
+ super(type);
+ setFilterClass(ImageFilterRedEye.class);
+ setPriority(FilterRepresentation.TYPE_NORMAL);
+ setTextId(textid);
+ setEditorId(editorID);
+ }
+
+ @Override
+ public FilterRepresentation clone() throws CloneNotSupportedException {
+ FilterPointRepresentation representation = (FilterPointRepresentation) super
+ .clone();
+ representation.mCandidates = (Vector<FilterPoint>) mCandidates.clone();
+ return representation;
+ }
+
+ public boolean hasCandidates() {
+ return mCandidates != null;
+ }
+
+ public Vector<FilterPoint> getCandidates() {
+ return mCandidates;
+ }
+
+ @Override
+ public boolean isNil() {
+ if (getCandidates() != null && getCandidates().size() > 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public Object getCandidate(int index) {
+ return this.mCandidates.get(index);
+ }
+
+ public void addCandidate(FilterPoint c) {
+ this.mCandidates.add(c);
+ }
+
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ if (a instanceof FilterPointRepresentation) {
+ FilterPointRepresentation representation = (FilterPointRepresentation) a;
+ mCandidates.clear();
+ for (FilterPoint redEyeCandidate : representation.mCandidates) {
+ mCandidates.add(redEyeCandidate);
+ }
+ }
+ }
+
+ public void removeCandidate(RedEyeCandidate c) {
+ this.mCandidates.remove(c);
+ }
+
+ public void clearCandidates() {
+ this.mCandidates.clear();
+ }
+
+ public int getNumberOfCandidates() {
+ return mCandidates.size();
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
index 7779211df..70d016f69 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRedEyeRepresentation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,80 +24,19 @@ import com.android.gallery3d.filtershow.editors.EditorRedEye;
import java.util.Vector;
-public class FilterRedEyeRepresentation extends FilterRepresentation {
+public class FilterRedEyeRepresentation extends FilterPointRepresentation {
private static final String LOGTAG = "FilterRedEyeRepresentation";
- private Vector<RedEyeCandidate> mCandidates = new Vector<RedEyeCandidate>();
public FilterRedEyeRepresentation() {
- super("RedEye");
+ super("RedEye",R.string.redeye,EditorRedEye.ID);
setFilterClass(ImageFilterRedEye.class);
- setPriority(FilterRepresentation.TYPE_NORMAL);
- setTextId(R.string.redeye);
- setEditorId(EditorRedEye.ID);
setOverlayId(R.drawable.photoeditor_effect_redeye);
}
- @Override
- public FilterRepresentation clone() throws CloneNotSupportedException {
- FilterRedEyeRepresentation representation = (FilterRedEyeRepresentation) super
- .clone();
- representation.mCandidates = (Vector<RedEyeCandidate>) mCandidates.clone();
- return representation;
- }
-
- public boolean hasCandidates() {
- return mCandidates != null;
- }
-
- public Vector<RedEyeCandidate> getCandidates() {
- return mCandidates;
- }
-
- public void setCandidates(Vector<RedEyeCandidate> mCandidates) {
- this.mCandidates = mCandidates;
- }
-
- public RedEyeCandidate getCandidate(int index) {
- return this.mCandidates.get(index);
- }
-
- public void addCandidate(RedEyeCandidate c) {
- 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);
- }
-
- public void clearCandidates() {
- this.mCandidates.clear();
- }
-
- public int getNumberOfCandidates() {
- if (mCandidates == null) {
- return 0;
- }
- return mCandidates.size();
- }
-
public void addRect(RectF rect, RectF bounds) {
- if (!hasCandidates()) {
- setCandidates(new Vector<RedEyeCandidate>());
- }
Vector<RedEyeCandidate> intersects = new Vector<RedEyeCandidate>();
for (int i = 0; i < getCandidates().size(); i++) {
- RedEyeCandidate r = getCandidate(i);
+ RedEyeCandidate r = (RedEyeCandidate) getCandidate(i);
if (r.intersect(rect)) {
intersects.add(r);
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 7c5a75232..614c6a01d 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -17,9 +17,11 @@
package com.android.gallery3d.filtershow.filters;
import android.graphics.Bitmap;
+import android.graphics.Matrix;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.BasicEditor;
+import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.presets.ImagePreset;
public abstract class ImageFilter implements Cloneable {
@@ -67,4 +69,12 @@ public abstract class ImageFilter implements Cloneable {
return null;
}
+ protected Matrix getOriginalToScreenMatrix(int w, int h) {
+ GeometryMetadata geo = getImagePreset().mGeoData;
+ Matrix originalToScreen = geo.getOriginalToScreen(true,
+ getImagePreset().getImageLoader().getOriginalBounds().width(),
+ getImagePreset().getImageLoader().getOriginalBounds().height(),
+ w, h);
+ return originalToScreen;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index 4b21d3595..6d7614ec9 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -267,11 +267,8 @@ public class ImageFilterDraw extends ImageFilter {
public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
- ImagePreset imgPreset = getImagePreset();
- Rect bounds = imgPreset.getImageLoader().getOriginalBounds();
- Matrix m = imgPreset.mGeoData.getOriginalToScreen(true,
- bounds.width(),
- bounds.height(), w, h);
+
+ Matrix m = getOriginalToScreenMatrix(w, h);
drawData(new Canvas(bitmap), m, quality);
return bitmap;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
index 42587c06f..511f9e90f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,14 +17,8 @@
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.filtershow.imageshow.GeometryMetadata;
import java.util.Vector;
@@ -42,23 +36,14 @@ public class ImageFilterRedEye extends ImageFilter {
}
public boolean isNil() {
- if (mParameters.getCandidates() != null && mParameters.getCandidates().size() > 0) {
- return false;
- }
- return true;
+ return mParameters.isNil();
}
- public Vector<RedEyeCandidate> getCandidates() {
- if (!mParameters.hasCandidates()) {
- mParameters.setCandidates(new Vector<RedEyeCandidate>());
- }
+ public Vector<FilterPoint> getCandidates() {
return mParameters.getCandidates();
}
public void clear() {
- if (!mParameters.hasCandidates()) {
- mParameters.setCandidates(new Vector<RedEyeCandidate>());
- }
mParameters.clearCandidates();
}
@@ -75,46 +60,19 @@ public class ImageFilterRedEye extends ImageFilter {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
short[] rect = new short[4];
+
int size = mParameters.getNumberOfCandidates();
+ Matrix originalToScreen = getOriginalToScreenMatrix(w, h);
for (int i = 0; i < size; i++) {
- RectF r = new RectF(mParameters.getCandidate(i).mRect);
- GeometryMetadata geo = getImagePreset().mGeoData;
- Matrix originalToScreen = geo.getOriginalToScreen(true,
- getImagePreset().getImageLoader().getOriginalBounds().width(),
- getImagePreset().getImageLoader().getOriginalBounds().height(),
- w, h);
+ RectF r = new RectF(((RedEyeCandidate) (mParameters.getCandidate(i))).mRect);
originalToScreen.mapRect(r);
- if (r.left < 0) {
- r.left = 0;
- }
- if (r.left > w) {
- r.left = w;
- }
- if (r.top < 0) {
- r.top = 0;
+ if (r.intersect(0, 0, w, 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);
}
- if (r.top > h) {
- r.top = h;
- }
- if (r.right < 0) {
- r.right = 0;
- }
- if (r.right > w) {
- r.right = w;
- }
- if (r.bottom < 0) {
- r.bottom = 0;
- }
- 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/RedEyeCandidate.java b/src/com/android/gallery3d/filtershow/filters/RedEyeCandidate.java
index 58d3afa3b..a40d4fa3b 100644
--- a/src/com/android/gallery3d/filtershow/filters/RedEyeCandidate.java
+++ b/src/com/android/gallery3d/filtershow/filters/RedEyeCandidate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package com.android.gallery3d.filtershow.filters;
import android.graphics.RectF;
-public class RedEyeCandidate {
+public class RedEyeCandidate implements FilterPoint {
RectF mRect = new RectF();
RectF mBounds = new RectF();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java b/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java
new file mode 100644
index 000000000..06b055d3c
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImagePoint.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.imageshow;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Matrix;
+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;
+import com.android.gallery3d.filtershow.filters.FilterPoint;
+import com.android.gallery3d.filtershow.filters.FilterRedEyeRepresentation;
+import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
+import com.android.gallery3d.filtershow.filters.RedEyeCandidate;
+
+public abstract class ImagePoint extends ImageShow {
+
+ private static final String LOGTAG = "ImageRedEyes";
+ protected EditorRedEye mEditorRedEye;
+ protected FilterRedEyeRepresentation mRedEyeRep;
+ protected static float mTouchPadding = 80;
+
+ public static void setTouchPadding(float padding) {
+ mTouchPadding = padding;
+ }
+
+ public ImagePoint(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public ImagePoint(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void resetParameter() {
+ ImageFilterRedEye filter = (ImageFilterRedEye) getCurrentFilter();
+ if (filter != null) {
+ filter.clear();
+ }
+ invalidate();
+ }
+
+ @Override
+ public void updateImage() {
+ super.updateImage();
+ invalidate();
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ Paint paint = new Paint();
+ paint.setStyle(Style.STROKE);
+ paint.setColor(Color.RED);
+ paint.setStrokeWidth(2);
+
+ GeometryMetadata geo = getImagePreset().mGeoData;
+ Matrix originalToScreen = geo.getOriginalToScreen(false,
+ mImageLoader.getOriginalBounds().width(),
+ mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
+ Matrix originalRotateToScreen = geo.getOriginalToScreen(true,
+ mImageLoader.getOriginalBounds().width(),
+ mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
+ if (mRedEyeRep != null) {
+ for (FilterPoint candidate : mRedEyeRep.getCandidates()) {
+ drawPoint(candidate, canvas, originalToScreen, originalRotateToScreen, paint);
+ }
+ }
+ }
+
+ protected abstract void drawPoint(
+ FilterPoint candidate, Canvas canvas, Matrix originalToScreen,
+ Matrix originalRotateToScreen, Paint paint);
+
+ public void setEditor(EditorRedEye editorRedEye) {
+ mEditorRedEye = editorRedEye;
+ }
+
+ public void setRepresentation(FilterRedEyeRepresentation redEyeRep) {
+ mRedEyeRep = redEyeRep;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java
index ba3dcdd1d..c3ff5e151 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRedEye.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.android.gallery3d.filtershow.imageshow;
@@ -8,30 +23,14 @@ import android.graphics.Matrix;
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;
-import com.android.gallery3d.filtershow.filters.FilterRedEyeRepresentation;
-import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
+import com.android.gallery3d.filtershow.filters.FilterPoint;
import com.android.gallery3d.filtershow.filters.RedEyeCandidate;
-public class ImageRedEye extends ImageShow {
-
+public class ImageRedEye extends ImagePoint {
private static final String LOGTAG = "ImageRedEyes";
private RectF mCurrentRect = null;
- private EditorRedEye mEditorRedEye;
- private FilterRedEyeRepresentation mRedEyeRep;
- private static float mTouchPadding = 80;
-
- public static void setTouchPadding(float padding) {
- mTouchPadding = padding;
- }
-
- public ImageRedEye(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
public ImageRedEye(Context context) {
super(context);
@@ -39,21 +38,12 @@ public class ImageRedEye extends ImageShow {
@Override
public void resetParameter() {
- ImageFilterRedEye filter = (ImageFilterRedEye) getCurrentFilter();
- if (filter != null) {
- filter.clear();
- }
- mCurrentRect = null;
+ super.resetParameter();
invalidate();
}
@Override
- public void updateImage() {
- super.updateImage();
- invalidate();
- }
- @Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
float ex = event.getX();
@@ -112,49 +102,35 @@ public class ImageRedEye extends ImageShow {
RectF drawRect = new RectF(mCurrentRect);
canvas.drawRect(drawRect, paint);
}
-
- GeometryMetadata geo = getImagePreset().mGeoData;
- Matrix originalToScreen = geo.getOriginalToScreen(false,
- mImageLoader.getOriginalBounds().width(),
- mImageLoader.getOriginalBounds().height(), getWidth(), getHeight());
- 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();
- RectF drawRect = new RectF();
- originalToScreen.mapRect(drawRect, rect);
- RectF fullRect = new RectF();
- originalRotateToScreen.mapRect(fullRect, rect);
- paint.setColor(Color.BLUE);
- canvas.drawRect(fullRect, paint);
- canvas.drawLine(fullRect.centerX(), fullRect.top,
- fullRect.centerX(), fullRect.bottom, paint);
- canvas.drawLine(fullRect.left, fullRect.centerY(),
- fullRect.right, fullRect.centerY(), paint);
- paint.setColor(Color.GREEN);
- float dw = drawRect.width();
- float dh = drawRect.height();
- float dx = fullRect.centerX() - dw / 2;
- float dy = fullRect.centerY() - dh / 2;
- drawRect.set(dx, dy, dx + dw, dy + dh);
- canvas.drawRect(drawRect, paint);
- canvas.drawLine(drawRect.centerX(), drawRect.top,
- drawRect.centerX(), drawRect.bottom, paint);
- canvas.drawLine(drawRect.left, drawRect.centerY(),
- drawRect.right, drawRect.centerY(), paint);
- canvas.drawCircle(drawRect.centerX(), drawRect.centerY(),
- mTouchPadding, paint);
- }
- }
}
- public void setEditor(EditorRedEye editorRedEye) {
- mEditorRedEye = editorRedEye;
- }
-
- public void setRepresentation(FilterRedEyeRepresentation redEyeRep) {
- mRedEyeRep = redEyeRep;
+ @Override
+ protected void drawPoint(FilterPoint point, Canvas canvas, Matrix originalToScreen,
+ Matrix originalRotateToScreen, Paint paint) {
+ RedEyeCandidate candidate = (RedEyeCandidate) point;
+ RectF rect = candidate.getRect();
+ RectF drawRect = new RectF();
+ originalToScreen.mapRect(drawRect, rect);
+ RectF fullRect = new RectF();
+ originalRotateToScreen.mapRect(fullRect, rect);
+ paint.setColor(Color.BLUE);
+ canvas.drawRect(fullRect, paint);
+ canvas.drawLine(fullRect.centerX(), fullRect.top,
+ fullRect.centerX(), fullRect.bottom, paint);
+ canvas.drawLine(fullRect.left, fullRect.centerY(),
+ fullRect.right, fullRect.centerY(), paint);
+ paint.setColor(Color.GREEN);
+ float dw = drawRect.width();
+ float dh = drawRect.height();
+ float dx = fullRect.centerX() - dw / 2;
+ float dy = fullRect.centerY() - dh / 2;
+ drawRect.set(dx, dy, dx + dw, dy + dh);
+ canvas.drawRect(drawRect, paint);
+ canvas.drawLine(drawRect.centerX(), drawRect.top,
+ drawRect.centerX(), drawRect.bottom, paint);
+ canvas.drawLine(drawRect.left, drawRect.centerY(),
+ drawRect.right, drawRect.centerY(), paint);
+ canvas.drawCircle(drawRect.centerX(), drawRect.centerY(),
+ mTouchPadding, paint);
}
}