diff options
| author | Ruei-sung Lin <rslin@google.com> | 2011-09-19 14:33:17 +0800 |
|---|---|---|
| committer | Ruei-sung Lin <rslin@google.com> | 2011-09-30 10:53:15 -0700 |
| commit | d37ff2eef80634dabd2f37ecfe6993ae56efb2d4 (patch) | |
| tree | 8f0c6629544e3cd78ec9a91c2da7e08a175796fb | |
| parent | 75ebc879150db8ebe77e95217d0b4d1a132d40b6 (diff) | |
| download | android_packages_apps_Gallery2-d37ff2eef80634dabd2f37ecfe6993ae56efb2d4.tar.gz android_packages_apps_Gallery2-d37ff2eef80634dabd2f37ecfe6993ae56efb2d4.tar.bz2 android_packages_apps_Gallery2-d37ff2eef80634dabd2f37ecfe6993ae56efb2d4.zip | |
facelift in gallery
Change-Id: I7cb67c3d977d8b23957586bb5ad1dada096ef07b
| -rw-r--r-- | AndroidManifest.xml | 9 | ||||
| -rw-r--r-- | res/drawable/photoeditor_effect_facelift.png | bin | 0 -> 1799 bytes | |||
| -rw-r--r-- | res/layout/photoeditor_effects_fix.xml | 10 | ||||
| -rw-r--r-- | res/values/photoeditor_strings.xml | 6 | ||||
| -rw-r--r-- | src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java | 62 | ||||
| -rw-r--r-- | src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java | 49 |
6 files changed, 132 insertions, 4 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 846cae6fa..11e59abd2 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -204,12 +204,13 @@ <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> + <uses-library android:name="com.google.android.media.effects" + android:required="false" /> <activity android:name="com.android.gallery3d.app.SlideshowDream" - android:label="@string/slideshow_dream_name" - android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" - android:hardwareAccelerated="true" - > + android:label="@string/slideshow_dream_name" + android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" + android:hardwareAccelerated="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/res/drawable/photoeditor_effect_facelift.png b/res/drawable/photoeditor_effect_facelift.png Binary files differnew file mode 100644 index 000000000..ba845b5ee --- /dev/null +++ b/res/drawable/photoeditor_effect_facelift.png diff --git a/res/layout/photoeditor_effects_fix.xml b/res/layout/photoeditor_effects_fix.xml index b77ffd132..b8ed52477 100644 --- a/res/layout/photoeditor_effects_fix.xml +++ b/res/layout/photoeditor_effects_fix.xml @@ -40,6 +40,16 @@ android:text="@string/redeye" style="@style/EffectLabel"/> </com.android.gallery3d.photoeditor.actions.RedEyeAction> + <com.android.gallery3d.photoeditor.actions.FaceliftAction style="@style/Effect"> + <ImageButton + android:id="@+id/effect_button" + style="@style/EffectIcon" + android:src="@drawable/photoeditor_effect_facelift"/> + <TextView + android:id="@+id/effect_label" + android:text="@string/facelift" + style="@style/EffectLabel"/> + </com.android.gallery3d.photoeditor.actions.FaceliftAction> <com.android.gallery3d.photoeditor.actions.StraightenAction style="@style/Effect" android:tag="@string/straighten_tooltip"> <ImageButton diff --git a/res/values/photoeditor_strings.xml b/res/values/photoeditor_strings.xml index e05480c85..4a5d34669 100644 --- a/res/values/photoeditor_strings.xml +++ b/res/values/photoeditor_strings.xml @@ -60,6 +60,12 @@ <!-- Name for the photo effect that makes photo only two color tones. [CHAR LIMIT=15] --> <string name="duotone">Duo-tone</string> + <!-- Name for the photo effect that smooths facial skins. [CHAR LIMIT=15] --> + <string name="facelift">Face Glow</string> + + <!-- Name for the photo effect that tans facial skins. [CHAR LIMIT=15] --> + <string name="facetan">Face Tan</string> + <!-- Name for the photo effect that fills back-light. [CHAR LIMIT=15] --> <string name="filllight">Fill Light</string> diff --git a/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java new file mode 100644 index 000000000..90d4e0c72 --- /dev/null +++ b/src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 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.photoeditor.actions; + +import android.content.Context; +import android.util.AttributeSet; + +import com.android.gallery3d.photoeditor.filters.FaceliftFilter; + +/** + * An action handling facelift effect. + */ +public class FaceliftAction extends EffectAction { + + private static final float DEFAULT_SCALE = 0.5f; + + private ScaleSeekBar scalePicker; + + public FaceliftAction(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void doBegin() { + final FaceliftFilter filter = new FaceliftFilter(); + + scalePicker = factory.createScalePicker(EffectToolFactory.ScalePickerType.GENERIC); + scalePicker.setOnScaleChangeListener(new ScaleSeekBar.OnScaleChangeListener() { + + @Override + public void onProgressChanged(float progress, boolean fromUser) { + if (fromUser) { + filter.setScale(progress); + notifyFilterChanged(filter, true); + } + } + }); + scalePicker.setProgress(DEFAULT_SCALE); + + filter.setScale(DEFAULT_SCALE); + notifyFilterChanged(filter, true); + } + + @Override + public void doEnd() { + scalePicker.setOnScaleChangeListener(null); + } +} diff --git a/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java new file mode 100644 index 000000000..3fa2e31b7 --- /dev/null +++ b/src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 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.photoeditor.filters; + +import android.media.effect.Effect; +import android.media.effect.EffectContext; +import android.media.effect.EffectFactory; + +import com.android.gallery3d.photoeditor.Photo; + +/** + * Facelift filter applied to the image. + */ +public class FaceliftFilter extends Filter { + + private float scale; + + /** + * Sets the facelift level. + * + * @param scale ranges from 0 to 1. + */ + public void setScale(float scale) { + this.scale = scale; + validate(); + } + + @Override + public void process(EffectContext context, Photo src, Photo dst) { + Effect effect = getEffect(context, + "com.google.android.media.effect.effects.FaceliftEffect"); + effect.setParameter("blend", scale); + effect.apply(src.texture(), src.width(), src.height(), dst.texture()); + } +} |
