summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor
diff options
context:
space:
mode:
authorRuei-sung Lin <rslin@google.com>2011-09-19 14:33:17 +0800
committerRuei-sung Lin <rslin@google.com>2011-09-30 10:53:15 -0700
commite0856697e69a7802040c004232e4cdec4113a88e (patch)
treea0a90211c4547d1507f727d2a889e7570c64c044 /src/com/android/gallery3d/photoeditor
parent4074ff352ed8fafd2146eec9c6356b9b5e3bcd94 (diff)
downloadandroid_packages_apps_Snap-e0856697e69a7802040c004232e4cdec4113a88e.tar.gz
android_packages_apps_Snap-e0856697e69a7802040c004232e4cdec4113a88e.tar.bz2
android_packages_apps_Snap-e0856697e69a7802040c004232e4cdec4113a88e.zip
facelift in gallery
Change-Id: I7cb67c3d977d8b23957586bb5ad1dada096ef07b
Diffstat (limited to 'src/com/android/gallery3d/photoeditor')
-rw-r--r--src/com/android/gallery3d/photoeditor/actions/FaceliftAction.java62
-rw-r--r--src/com/android/gallery3d/photoeditor/filters/FaceliftFilter.java49
2 files changed, 111 insertions, 0 deletions
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());
+ }
+}