Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [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 | 08e2b47 | 2011-10-13 18:20:07 -0700 | [diff] [blame] | 21 | |
| 22 | import com.android.gallery3d.photoeditor.Photo; |
| 23 | |
| 24 | /** |
| 25 | * Face tanning filter applied to the image. |
| 26 | */ |
Yuli Huang | 738e82e | 2011-11-04 16:39:50 +0800 | [diff] [blame] | 27 | public class FaceTanFilter extends AbstractScaleFilter { |
Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [diff] [blame] | 28 | |
Yuli Huang | 738e82e | 2011-11-04 16:39:50 +0800 | [diff] [blame] | 29 | public static final Creator<FaceTanFilter> CREATOR = creatorOf(FaceTanFilter.class); |
Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [diff] [blame] | 30 | |
Jorge Ruesga | a901f88 | 2012-06-12 23:28:58 +0200 | [diff] [blame^] | 31 | private static final String EFFECT_FACE_TANNING = "com.google.android.media.effect.effects.FaceTanningEffect"; |
| 32 | |
Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [diff] [blame] | 33 | @Override |
| 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_FACE_TANNING); |
Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [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_FACE_TANNING); |
| 47 | } |
| 48 | |
Ruei-sung Lin | 08e2b47 | 2011-10-13 18:20:07 -0700 | [diff] [blame] | 49 | } |