Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.gallery3d.photoeditor.filters; |
| 18 | |
| 19 | import android.media.effect.Effect; |
Jorge Ruesga | a901f88 | 2012-06-12 23:28:58 +0200 | [diff] [blame^] | 20 | import android.media.effect.EffectFactory; |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 21 | |
| 22 | import com.android.gallery3d.photoeditor.Photo; |
| 23 | |
| 24 | /** |
| 25 | * Facelift filter applied to the image. |
| 26 | */ |
Yuli Huang | 738e82e | 2011-11-04 16:39:50 +0800 | [diff] [blame] | 27 | public class FaceliftFilter extends AbstractScaleFilter { |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 28 | |
Yuli Huang | 738e82e | 2011-11-04 16:39:50 +0800 | [diff] [blame] | 29 | public static final Creator<FaceliftFilter> CREATOR = creatorOf(FaceliftFilter.class); |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 30 | |
Jorge Ruesga | a901f88 | 2012-06-12 23:28:58 +0200 | [diff] [blame^] | 31 | private static final String EFFECT_FACELIFT = "com.google.android.media.effect.effects.FaceliftEffect"; |
| 32 | |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 33 | @Override |
Yuli Huang | c7e39d1 | 2011-10-05 16:22:10 +0800 | [diff] [blame] | 34 | public void process(Photo src, Photo dst) { |
Jorge Ruesga | a901f88 | 2012-06-12 23:28:58 +0200 | [diff] [blame^] | 35 | Effect effect = getEffect(EFFECT_FACELIFT); |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 36 | effect.setParameter("blend", scale); |
| 37 | effect.apply(src.texture(), src.width(), src.height(), dst.texture()); |
| 38 | } |
Jorge Ruesga | a901f88 | 2012-06-12 23:28:58 +0200 | [diff] [blame^] | 39 | |
| 40 | /** |
| 41 | * Checks if the effect is present in the system. |
| 42 | * |
| 43 | * @return boolean true if an effect is present in the system and can be loaded |
| 44 | */ |
| 45 | public static boolean isPresent() { |
| 46 | return EffectFactory.isEffectSupported(EFFECT_FACELIFT); |
| 47 | } |
Ruei-sung Lin | d37ff2e | 2011-09-19 14:33:17 +0800 | [diff] [blame] | 48 | } |