summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java21
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java3
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java13
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java17
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java12
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java7
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java13
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java54
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java52
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java55
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java53
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java5
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java7
-rw-r--r--src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java82
16 files changed, 364 insertions, 33 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index 8350ff356..e93175a92 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -36,6 +36,7 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
protected ArrayList<FilterRepresentation> mBorders = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mTools = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mEffects = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mMakeup = new ArrayList<FilterRepresentation>();
private static int mImageBorderSize = 4; // in percent
protected void init() {
@@ -140,6 +141,12 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
filters.add(ImageFilterFx.class);
filters.add(ImageFilterBorder.class);
filters.add(ImageFilterColorBorder.class);
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ filters.add(ImageFilterMakeupWhiten.class);
+ filters.add(ImageFilterMakeupSoften.class);
+ filters.add(ImageFilterMakeupTrimface.class);
+ filters.add(ImageFilterMakeupBigeye.class);
+ }
}
public ArrayList<FilterRepresentation> getLooks() {
@@ -158,8 +165,11 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
return mEffects;
}
- public void addBorders(Context context) {
+ public ArrayList<FilterRepresentation> getMakeup() {
+ return mMakeup;
+ }
+ public void addBorders(Context context) {
// Do not localize
String[] serializationNames = {
"FRAME_4X5",
@@ -305,6 +315,15 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
mEffects.add(getRepresentation(ImageFilterKMeans.class));
}
+ public void addMakeups(Context context) {
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ mMakeup.add(getRepresentation(ImageFilterMakeupWhiten.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupSoften.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupTrimface.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupBigeye.class));
+ }
+ }
+
public void addTools(Context context) {
int[] textId = {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java
index ba697d87f..98afc3a08 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterCropRepresentation.java
@@ -65,6 +65,9 @@ public class FilterCropRepresentation extends FilterRepresentation {
return false;
}
FilterCropRepresentation crop = (FilterCropRepresentation) rep;
+ if (crop.isNil()) {
+ return true;
+ }
if (mCrop.bottom != crop.mCrop.bottom
|| mCrop.left != crop.mCrop.left
|| mCrop.right != crop.mCrop.right
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
index 48d3d9077..5c5e561ca 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
@@ -157,15 +157,20 @@ public class FilterDrawRepresentation extends FilterRepresentation {
private Vector<StrokeData> mDrawing = new Vector<StrokeData>();
private StrokeData mCurrent; // used in the currently drawing style
- public FilterDrawRepresentation() {
- super("Draw");
+ public FilterDrawRepresentation(String name) {
+ super(name);
setFilterClass(ImageFilterDraw.class);
- setSerializationName("DRAW");
+ setSerializationName(name);
setFilterType(FilterRepresentation.TYPE_VIGNETTE);
setTextId(R.string.imageDraw);
setEditorId(EditorDraw.ID);
setOverlayId(R.drawable.filtershow_drawing);
setOverlayOnly(true);
+ setDefaultColor();
+ }
+
+ private void setDefaultColor() {
+ mParamColor.setValue(DEFAULT_MENU_COLOR1);
}
@Override
@@ -185,7 +190,7 @@ public class FilterDrawRepresentation extends FilterRepresentation {
@Override
public FilterRepresentation copy() {
- FilterDrawRepresentation representation = new FilterDrawRepresentation();
+ FilterDrawRepresentation representation = new FilterDrawRepresentation(getName());
copyAllParameters(representation);
return representation;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 0fb157d7b..36675b71b 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -47,6 +47,7 @@ public class FilterRepresentation {
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
public static final byte TYPE_GEOMETRY = 7;
+ public static final byte TYPE_MAKEUP = 8;
protected static final String NAME_TAG = "Name";
public FilterRepresentation(String name) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 437137416..1fcd3008c 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -19,7 +19,7 @@ package com.android.gallery3d.filtershow.filters;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
-import android.support.v8.renderscript.Allocation;
+import android.renderscript.Allocation;
import android.widget.Toast;
import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
index a7286f0fa..5f3502272 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterBorder.java
@@ -18,13 +18,15 @@ package com.android.gallery3d.filtershow.filters;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import com.android.gallery3d.data.DecodeUtils;
+
import java.util.HashMap;
+import java.lang.ref.WeakReference;
public class ImageFilterBorder extends ImageFilter {
private static final float NINEPATCH_ICON_SCALING = 10;
@@ -32,7 +34,7 @@ public class ImageFilterBorder extends ImageFilter {
private FilterImageBorderRepresentation mParameters = null;
private Resources mResources = null;
- private HashMap<Integer, Drawable> mDrawables = new HashMap<Integer, Drawable>();
+ private HashMap<Integer, WeakReference<Drawable>> mDrawables = new HashMap<Integer, WeakReference<Drawable>>();
public ImageFilterBorder() {
mName = "Border";
@@ -57,7 +59,7 @@ public class ImageFilterBorder extends ImageFilter {
Rect bounds = new Rect(0, 0, (int) (w * scale1), (int) (h * scale1));
Canvas canvas = new Canvas(bitmap);
canvas.scale(scale2, scale2);
- Drawable drawable = getDrawable(getParameters().getDrawableResource());
+ Drawable drawable = getDrawable(getParameters().getDrawableResource(), w, h);
drawable.setBounds(bounds);
drawable.draw(canvas);
return bitmap;
@@ -80,11 +82,12 @@ public class ImageFilterBorder extends ImageFilter {
}
}
- public Drawable getDrawable(int rsc) {
- Drawable drawable = mDrawables.get(rsc);
+ public Drawable getDrawable(int rsc, int reqWidth, int reqHeight) {
+ Drawable drawable = (mDrawables.get(rsc) != null) ? mDrawables.get(rsc).get() : null;
if (drawable == null && mResources != null && rsc != 0) {
- drawable = new BitmapDrawable(mResources, BitmapFactory.decodeResource(mResources, rsc));
- mDrawables.put(rsc, drawable);
+ drawable = new BitmapDrawable(mResources, DecodeUtils.decodeBitmap(
+ mResources, rsc, reqWidth, reqHeight));
+ mDrawables.put(rsc, new WeakReference<Drawable>(drawable));
}
return drawable;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java
index 5d3856ebc..6c48a6a9f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterChanSat.java
@@ -18,11 +18,11 @@ package com.android.gallery3d.filtershow.filters;
import android.graphics.Bitmap;
import android.graphics.Matrix;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.Element;
-import android.support.v8.renderscript.RenderScript;
-import android.support.v8.renderscript.Script.LaunchOptions;
-import android.support.v8.renderscript.Type;
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.Script;
+import android.renderscript.Type;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
@@ -132,7 +132,7 @@ public class ImageFilterChanSat extends ImageFilterRS {
int width = in.getType().getX();
int height = in.getType().getY();
- LaunchOptions options = new LaunchOptions();
+ Script.LaunchOptions options = new Script.LaunchOptions();
int ty;
options.setX(0, width);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
index 8fd5b029e..da7de9379 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java
@@ -29,6 +29,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import com.android.gallery3d.R;
+import com.android.gallery3d.app.GalleryAppImpl;
import com.android.gallery3d.app.Log;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation.StrokeData;
@@ -47,7 +48,8 @@ public class ImageFilterDraw extends ImageFilter {
int mCachedStrokes = -1;
int mCurrentStyle = 0;
- FilterDrawRepresentation mParameters = new FilterDrawRepresentation();
+ FilterDrawRepresentation mParameters = new FilterDrawRepresentation(
+ GalleryAppImpl.getContext().getString(R.string.imageDraw));
public ImageFilterDraw() {
mName = "Image Draw";
@@ -69,7 +71,8 @@ public class ImageFilterDraw extends ImageFilter {
@Override
public FilterRepresentation getDefaultRepresentation() {
- return new FilterDrawRepresentation();
+ return new FilterDrawRepresentation(
+ GalleryAppImpl.getContext().getString(R.string.imageDraw));
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java
index 0a615afd4..7f10af990 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGrad.java
@@ -26,11 +26,12 @@ import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.Element;
-import android.support.v8.renderscript.RenderScript;
-import android.support.v8.renderscript.Script.LaunchOptions;
-import android.support.v8.renderscript.Type;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.Script;
+import android.renderscript.Type;
import android.util.Log;
import com.android.gallery3d.R;
@@ -161,7 +162,7 @@ public class ImageFilterGrad extends ImageFilterRS {
int width = in.getType().getX();
int height = in.getType().getY();
- LaunchOptions options = new LaunchOptions();
+ Script.LaunchOptions options = new Script.LaunchOptions();
int ty;
options.setX(0, width);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java
new file mode 100644
index 000000000..64067881e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java
@@ -0,0 +1,54 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupBigeye extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "BIGEYE";
+
+ public ImageFilterMakeupBigeye() {
+ mName = "Bigeye";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Bigeye");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupBigeye.class);
+ representation.setTextId(R.string.text_makeup_bigeye);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_bigeye);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value) {
+ MakeupEngine.doWarpFace(bitmap, bitmap, width, height, faceInfo.eye1, faceInfo.eye2,
+ faceInfo.mouth, value, 0);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java
new file mode 100644
index 000000000..8587158c3
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java
@@ -0,0 +1,52 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupSoften extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "SOFTEN";
+
+ public ImageFilterMakeupSoften() {
+ mName = "Soften";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Soften");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupSoften.class);
+ representation.setTextId(R.string.text_makeup_Soften);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_soften);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height, int value) {
+ MakeupEngine.doProcessBeautify(bitmap, bitmap, width, height, faceInfo.face, value, 0);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java
new file mode 100644
index 000000000..4b0499036
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java
@@ -0,0 +1,55 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupTrimface extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "TRIMFACE";
+
+ public ImageFilterMakeupTrimface() {
+ mName = "Trimface";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Trimface");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupTrimface.class);
+ representation.setTextId(R.string.text_makeup_trimface);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_trimface);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value) {
+ MakeupEngine.doWarpFace(bitmap, bitmap, width, height, faceInfo.eye1, faceInfo.eye2,
+ faceInfo.mouth, 0, value);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java
new file mode 100644
index 000000000..e60be84d7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupWhiten extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "WHITEN";
+
+ public ImageFilterMakeupWhiten() {
+ mName = "Whiten";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Whiten");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupWhiten.class);
+ representation.setTextId(R.string.text_makeup_whiten);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_whiten);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height, int value) {
+ MakeupEngine.doProcessBeautify(bitmap, bitmap, width, height, faceInfo.face, 0, value);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
index e94e2a63a..b7c4d80e0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterRS.java
@@ -18,7 +18,10 @@ package com.android.gallery3d.filtershow.filters;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.support.v8.renderscript.*;
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.RenderScript;
+import android.renderscript.Type;
import android.util.Log;
import android.content.res.Resources;
import com.android.gallery3d.R;
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
index e0b4cf687..279bd1857 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterVignette.java
@@ -24,11 +24,8 @@ import android.graphics.Rect;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.pipeline.FilterEnvironment;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.Element;
-import android.support.v8.renderscript.RenderScript;
-import android.support.v8.renderscript.Script.LaunchOptions;
-import android.support.v8.renderscript.Type;
+
+import android.renderscript.RenderScript;
import android.util.Log;
public class ImageFilterVignette extends ImageFilterRS {
diff --git a/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java b/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java
new file mode 100644
index 000000000..584074c02
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java
@@ -0,0 +1,82 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+
+import com.thundersoft.hz.selfportrait.detect.FaceDetect;
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+
+public abstract class SimpleMakeupImageFilter extends SimpleImageFilter {
+ private static final String LOGTAG = "SimpleMakeupImageFilter";
+ protected static final int MAKEUP_INTENSITY = 50;
+
+ public static final boolean HAS_TS_MAKEUP = android.os.SystemProperties.getBoolean("persist.ts.postmakeup", false);
+
+ public SimpleMakeupImageFilter() {
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterRepresentation representation = new FilterBasicRepresentation("Default", 0,
+ MAKEUP_INTENSITY, 100);
+ representation.setShowParameterValue(true);
+ return representation;
+ }
+
+ protected FaceInfo detectFaceInfo(Bitmap bitmap) {
+ FaceDetect faceDetect = new FaceDetect();
+ faceDetect.initialize();
+ FaceInfo[] faceInfos = faceDetect.dectectFeatures(bitmap);
+ faceDetect.uninitialize();
+
+ Log.v(LOGTAG, "SimpleMakeupImageFilter.detectFaceInfo(): detect faceNum is "
+ + (faceInfos != null ? faceInfos.length : "NULL"));
+ if (faceInfos == null || faceInfos.length <= 0) {
+ return null;
+ }
+
+ return faceInfos[0];
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
+ if (getParameters() == null) {
+ return bitmap;
+ }
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ if(w % 2 != 0 || h % 2 != 0) {
+ return bitmap;
+ }
+ int value = getParameters().getValue();
+ applyHelper(bitmap, w, h, value);
+ return bitmap;
+ }
+
+ private void applyHelper(Bitmap bitmap, int w, int h, int value) {
+ FaceInfo faceInfo = detectFaceInfo(bitmap);
+ if(faceInfo != null) {
+ doMakeupEffect(bitmap, faceInfo, w, h, value);
+ }
+ }
+
+ abstract void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value);
+
+}