diff options
author | John Hoford <hoford@google.com> | 2012-10-08 15:21:37 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-08 15:21:37 -0700 |
commit | a3ecbd9cac6f92b40081d148ba49156cefefbc4b (patch) | |
tree | 77514efd98b68202f5bab0c6463ec6ee2f13cb9e /src/com | |
parent | 174187340a7f68ff083c60b392d65a0b5e9eb64a (diff) | |
parent | 685bc7b98b1528ee177a277dfad4f5da8563fe25 (diff) | |
download | android_packages_apps_Snap-a3ecbd9cac6f92b40081d148ba49156cefefbc4b.tar.gz android_packages_apps_Snap-a3ecbd9cac6f92b40081d148ba49156cefefbc4b.tar.bz2 android_packages_apps_Snap-a3ecbd9cac6f92b40081d148ba49156cefefbc4b.zip |
am 1a291db0: Merge "add redeye and improve shadow removal" into gb-ub-photos-arches
* commit '1a291db030b2f3f7752026dd347ec34b82f8891e':
add redeye and improve shadow removal
Diffstat (limited to 'src/com')
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; } } |