summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2012-10-08 14:21:57 -0700
committerJohn Hoford <hoford@google.com>2012-10-08 15:03:10 -0700
commit86aa80d008745a3717666d6773f563865aa6029c (patch)
tree2985466bbbe73a979def61e1c1dcd239b59ca1d7
parentd922690a19edb8afbb103381f3a9c329ee2f9681 (diff)
downloadandroid_packages_apps_Snap-86aa80d008745a3717666d6773f563865aa6029c.tar.gz
android_packages_apps_Snap-86aa80d008745a3717666d6773f563865aa6029c.tar.bz2
android_packages_apps_Snap-86aa80d008745a3717666d6773f563865aa6029c.zip
add redeye and improve shadow removal
bug:7234321 Change-Id: I12c2eb28555d7594fddf86dfa224219b70137681
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java1
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java11
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java42
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java39
4 files changed, 57 insertions, 36 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 664b67f5c..6d61441eb 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -202,6 +202,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mPanelController.addComponent(mColorsButton, findViewById(R.id.tintButton));
mPanelController.addComponent(mColorsButton, findViewById(R.id.exposureButton));
mPanelController.addComponent(mColorsButton, findViewById(R.id.shadowRecoveryButton));
+ mPanelController.addComponent(mColorsButton, findViewById(R.id.redEyeButton));
mPanelController.addView(findViewById(R.id.resetEffect));
mPanelController.addView(findViewById(R.id.applyEffect));
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index dbb6f27b3..0c50046df 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -13,6 +13,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.filters.ImageFilterContrast;
import com.android.gallery3d.filtershow.filters.ImageFilterExposure;
import com.android.gallery3d.filtershow.filters.ImageFilterHue;
+import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
import com.android.gallery3d.filtershow.filters.ImageFilterShadows;
import com.android.gallery3d.filtershow.filters.ImageFilterSharpen;
@@ -368,6 +369,9 @@ public class PanelController implements OnClickListener {
if (filter == null && name.equalsIgnoreCase("Shadows")) {
filter = setImagePreset(new ImageFilterShadows(), name);
}
+ if (filter == null && name.equalsIgnoreCase("Redeye")) {
+ filter = setImagePreset(new ImageFilterRedEye(), name);
+ }
mMasterImage.setCurrentFilter(filter);
}
@@ -480,6 +484,13 @@ public class PanelController implements OnClickListener {
ensureFilter("Shadows");
break;
}
+ case R.id.redEyeButton: {
+ mCurrentImage = showImageView(R.id.imageShow).setShowControls(true);
+ mUtilityPanel.setEffectName("Redeye");
+ mUtilityPanel.setGeometryEffect(false);
+ ensureFilter("Redeye");
+ break;
+ }
case R.id.resetEffect: {
mCurrentImage.resetParameter();
break;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
new file mode 100644
index 000000000..c990c1870
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRedEye.java
@@ -0,0 +1,42 @@
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+
+import java.util.Arrays;
+
+public class ImageFilterRedEye extends ImageFilter {
+ private static final String TAG = "ImageFilterRedEye";
+
+
+ public ImageFilterRedEye() {
+ mName = "Redeye";
+
+ }
+
+ @Override
+ public ImageFilter clone() throws CloneNotSupportedException {
+ ImageFilterRedEye filter = (ImageFilterRedEye) super.clone();
+
+ return filter;
+ }
+
+ native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short []matrix);
+
+ public void apply(Bitmap bitmap) {
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ float p = mParameter;
+ float value = p;
+ int box = Math.min(w, h);
+ int sizex = Math.min((int)((p+100)*box/400),w/2);
+ int sizey = Math.min((int)((p+100)*box/800),h/2);
+
+ short [] rect = new short[]{
+ (short) (w/2-sizex),(short) (w/2-sizey),
+ (short) (2*sizex),(short) (2*sizey)};
+
+ nativeApplyFilter(bitmap, w, h, rect);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
index 9b379a1ff..ee621966d 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterShadows.java
@@ -3,61 +3,28 @@ package com.android.gallery3d.filtershow.filters;
import android.graphics.Bitmap;
-import com.android.gallery3d.filtershow.ui.ControlPoint;
-import com.android.gallery3d.filtershow.ui.Spline;
-
public class ImageFilterShadows extends ImageFilter {
- private final float SHADOW = .1f;
- private final float MID = .5f;
- private final float HIGHLIGHT = .9f;
-
- private final float []baseX = {0f,SHADOW,MID,HIGHLIGHT,1f};
- private final float []baseY = {0f,SHADOW,MID,HIGHLIGHT,1f};
public ImageFilterShadows() {
mName = "Shadows";
}
- short [] calcMap(){
- Spline sp = new Spline();
- for (int i = 0; i < baseX.length; i++) {
- sp.addPoint(baseX[i], baseY[i]);
- }
- int max = 4080;
- int w = 40800;
- float []px = new float[w+1];
- float []py = new float[w+1];
- short []vlut = new short[4080+1];
- for (int i = 0; i < px.length; i++) {
- float t = i/(float)(w);
-
- ControlPoint p = sp.getPoint(t);
- px[i] = p.x;
- py[i] = p.y;
- }
- for (int i = 0; i < py.length; i++) {
- short x = (short)Math.min(4080,Math.max(0,((int)(px[i]*max))));
- short y = (short)Math.min(4082,Math.max(0,((int)(py[i]*max))));
- vlut[x] = y;
- }
- return vlut;
- }
+
@Override
public ImageFilter clone() throws CloneNotSupportedException {
ImageFilterShadows filter = (ImageFilterShadows) super.clone();
return filter;
}
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, short []valMap);
+ native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float factor);
@Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
float p = mParameter;
- baseY[1] = (float)(SHADOW*Math.pow(4, mParameter/100.));
- nativeApplyFilter(bitmap, w, h, calcMap());
+ nativeApplyFilter(bitmap, w, h, p);
return bitmap;
}
}