diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-03-19 14:21:17 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-19 14:21:17 -0700 |
commit | 7e7035eaf5d8d8a72f5f61f05beb79b842e4f358 (patch) | |
tree | 87c85d50f5887d061492d76eeeb8e34546d96f6c | |
parent | 44fbc491a8209552a79eb34c30d4482e2d962868 (diff) | |
parent | 38478f2cfc651b58dd88274c9a3bb7526c91116b (diff) | |
download | android_packages_apps_Gallery2-7e7035eaf5d8d8a72f5f61f05beb79b842e4f358.tar.gz android_packages_apps_Gallery2-7e7035eaf5d8d8a72f5f61f05beb79b842e4f358.tar.bz2 android_packages_apps_Gallery2-7e7035eaf5d8d8a72f5f61f05beb79b842e4f358.zip |
Merge "Modify:Gallery2 for branch Gallery2"
26 files changed, 716 insertions, 10 deletions
diff --git a/Android.mk b/Android.mk index 0edfca54d..661dac6ae 100755 --- a/Android.mk +++ b/Android.mk @@ -39,6 +39,11 @@ LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D LOCAL_JNI_SHARED_LIBRARIES := libjni_eglfence libjni_filtershow_filters librsjni libjni_jpegstream +ifeq ($(TARGET_TS_MAKEUP), true) + LOCAL_JNI_SHARED_LIBRARIES := libts_detected_face_jni libts_face_beautify_jni + LOCAL_REQUIRED_MODULES := libts_detected_face_jni libts_face_beautify_jni +endif + LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_MULTILIB := 32 @@ -47,6 +52,12 @@ include $(BUILD_PACKAGE) ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),) +ifeq ($(TARGET_TS_MAKEUP), true) +include $(CLEAR_VARS) + LOCAL_PREBUILT_LIBS := jni_makeup_libs/libts_detected_face_jni.so jni_makeup_libs/libts_face_beautify_jni.so +include $(BUILD_MULTI_PREBUILT) +endif + # Use the following include to make gallery test apk include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java b/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java new file mode 100644 index 000000000..331d31b57 --- /dev/null +++ b/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java @@ -0,0 +1,44 @@ +/* +* 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.editors; + +import android.view.View; +import android.widget.SeekBar; + +import com.android.gallery3d.R; + +public class EditorMakeup extends BasicEditor { + public static int ID = R.id.editorMakeup; + private final String LOGTAG = "EditorMakeup"; + + public EditorMakeup() { + super(ID, R.layout.filtershow_default_editor, R.id.basicEditor); + } + + @Override + public void setUtilityPanelUI(View actionButton, View editControl) { + super.setUtilityPanelUI(actionButton, editControl); + mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar); + if (mSeekBar != null) { + mSeekBar.setVisibility(View.INVISIBLE); + } + } + + + +} diff --git a/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java new file mode 100644 index 000000000..64067881e --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java new file mode 100644 index 000000000..8587158c3 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java new file mode 100644 index 000000000..4b0499036 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java new file mode 100644 index 000000000..e60be84d7 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java new file mode 100644 index 000000000..584074c02 --- /dev/null +++ b/Gallery2/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); + +} diff --git a/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java new file mode 100644 index 000000000..a5c7fb043 --- /dev/null +++ b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java @@ -0,0 +1,79 @@ +/* +* 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.thundersoft.hz.selfportrait.detect; + +import android.graphics.Bitmap; +import android.graphics.Rect; +import android.util.Log; + +public class FaceDetect { + private static final String TAG = "FaceDetect"; + + private int mHandle = 0; + + static { + try { + System.loadLibrary("ts_detected_face_jni"); + } catch (UnsatisfiedLinkError e) { + e.printStackTrace(); + Log.e(TAG, "ts_detected_face_jni library not found!"); + } + } + + /** + * initialize method,MUST called at first time. + */ + public void initialize() { + mHandle = native_create(); + } + + /** + * uninitialize method,MUST called at last time. + */ + + public void uninitialize() { + native_destroy(mHandle); + } + + /** + * dectectFeatures method,MUST called after initialize method and before + * uninitialize method. + * + * @param bmp, Android Bitmap instance,MUST not null. + * @return FaceInfo array if success, otherwise return null. + */ + public FaceInfo[] dectectFeatures(Bitmap bmp) { + int count = native_detect(mHandle, bmp); + if (count < 1) { + return null; + } + FaceInfo[] res = new FaceInfo[count]; + for (int i = 0; i < count; i++) { + FaceInfo face = new FaceInfo(); + native_face_info(mHandle, i, face.face, face.eye1, face.eye2, face.mouth); + res[i] = face; + } + return res; + } + + private static native int native_create(); + private static native void native_destroy(int handle); + private static native int native_detect(int handle, Bitmap bmp); + private static native int native_face_info(int handle, int index, Rect face, Rect eye1, + Rect eye2, Rect mouth); +} diff --git a/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java new file mode 100644 index 000000000..eee51f71b --- /dev/null +++ b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java @@ -0,0 +1,39 @@ +/* +* 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.thundersoft.hz.selfportrait.detect; + +import android.graphics.Rect; + +public class FaceInfo { + /** + * face rectangle + */ + public Rect face = new Rect(); + /** + * left eye rectangle + */ + public Rect eye1 = new Rect(); + /** + * right eye rectangle + */ + public Rect eye2 = new Rect(); + /** + * mount rectangle + */ + public Rect mouth = new Rect(); +} diff --git a/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java b/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java new file mode 100644 index 000000000..8d58bcfef --- /dev/null +++ b/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java @@ -0,0 +1,87 @@ +/* +* 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.thundersoft.hz.selfportrait.makeup.engine; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Rect; +import android.util.Log; + +public class MakeupEngine { + static { + try { + System.loadLibrary("ts_face_beautify_jni"); + } catch (UnsatisfiedLinkError e) { + e.printStackTrace(); + Log.e(MakeupEngine.class.getName(), "ts_face_beautify_jni library not found!"); + } + } + + private static MakeupEngine mInstance; + + private MakeupEngine() { + + } + + public static MakeupEngine getMakeupObj() { + if(mInstance == null) { + mInstance = new MakeupEngine(); + } + + return mInstance; + } + + private Context mContext; + + public void setContext(Context context) { + mContext = context; + } + + public Context getContext() { + return mContext; + } + + /** + * FUNCTION: doProcessBeautify + * Do process face region clean and whiten. + * @param inBitmap, the Bitmap instance which have face region, MUST not null. + * @param outBitmap, the result of process, MUST not null. + * @param frameWidth,frameHeight, the size of inBitmap. + * @param faceRect, the face region in inBitmap. + * @param cleanLevel, the level of clean.(0-100) + * @param whiteLevel, the level of white.(0-100) + */ + public static native boolean doProcessBeautify(Bitmap inBitmap, Bitmap outBitmap, int frameWidth, int frameHeight, + Rect faceRect, int cleanLevel, int beautyLevel); + + /** + * FUNCTION: doWarpFace + * Do process face region warp and big eye. + * @param inBitmap, the Bitmap instance which have face region, MUST not null. + * @param outBitmap, the result of process, MUST not null. + * @param frameWidth, the size of inBitmap. + * @param frameHeight, the size of inBitmap. + * @param leftEye, the left eye rectangle + * @param rightEye, the right eye rectangle + * @param mouth, the mouth rectangle + * @param bigEyeLevel, the level of big eye.(0-100) + * @param trimFaceLevel, the level of trim face.(0-100) + */ + public static native boolean doWarpFace(Bitmap inBitmap, Bitmap outBitmap, int frameWidth, int frameHeight, + Rect leftEye, Rect rightEye, Rect mouth, int bigEyeLevel, int trimFaceLevel); +} diff --git a/proguard.flags b/proguard.flags index fc5aef3b7..d190434b7 100644 --- a/proguard.flags +++ b/proguard.flags @@ -88,3 +88,7 @@ -keep class com.android.gallery3d.jpegstream.JPEGOutputStream { *; } -keep class com.android.gallery3d.jpegstream.JPEGInputStream { *; } -keep class com.android.gallery3d.jpegstream.StreamUtils { *; } + +-keep class com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine{ + *; +} diff --git a/res/layout-land/filtershow_main_panel.xml b/res/layout-land/filtershow_main_panel.xml index 6a36de2d7..e508e767b 100644 --- a/res/layout-land/filtershow_main_panel.xml +++ b/res/layout-land/filtershow_main_panel.xml @@ -83,6 +83,16 @@ android:padding="2dip" android:scaleType="centerInside" android:src="@drawable/ic_photoeditor_color"/> + <ImageButton + android:id="@+id/makeupButton" + android:layout_width="@dimen/thumbnail_size" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@drawable/filtershow_button_background" + android:padding="2dip" + android:scaleType="centerInside" + android:visibility="gone" + android:src="@drawable/ic_photoeditor_makeup"/> </LinearLayout> diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml index d3400fae5..f8b26b088 100644 --- a/res/layout/filtershow_main_panel.xml +++ b/res/layout/filtershow_main_panel.xml @@ -95,8 +95,19 @@ android:scaleType="centerInside" android:src="@drawable/ic_photoeditor_color"/> + <ImageButton + android:id="@+id/makeupButton" + android:layout_width="@dimen/thumbnail_size" + android:layout_height="match_parent" + android:layout_weight="1" + android:padding="2dip" + android:background="@drawable/filtershow_button_background" + android:scaleType="centerInside" + android:visibility="gone" + android:src="@drawable/ic_photoeditor_makeup"/> + </LinearLayout> </com.android.gallery3d.filtershow.CenteredLinearLayout> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index ccb28f423..23bcb4508 100755 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -445,4 +445,8 @@ <string name="virtualizer_strength" msgid="5035111173763913313">"3D 音效"</string> <string name="audio_effects" msgid="612896145300512593">"音效"</string> <string name="headset_plug">“插入耳机体验音效”</string> + <string name="text_makeup_whiten">美白</string> + <string name="text_makeup_Soften">磨皮</string> + <string name="text_makeup_trimface">瘦脸</string> + <string name="text_makeup_bigeye">大眼</string> </resources> diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml index 460da61aa..58f16dcd1 100644 --- a/res/values/filtershow_ids.xml +++ b/res/values/filtershow_ids.xml @@ -50,4 +50,5 @@ <item type="id" name="editorParametric" /> <item type="id" name="editorGrad" /> <item type="id" name="editorChanSat" /> + <item type="id" name="editorMakeup" /> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 875a6e32d..1fef507dd 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1156,4 +1156,9 @@ CHAR LIMIT = NONE] --> <string name="drm_license_info">Drm license info</string> <string name="mimetype_not_supported">This file can not be played</string> <string name="action_consumes_rights">Rights will be consumed for playing this media</string> + <string name="text_makeup_whiten">Whiten</string> + <string name="text_makeup_Soften">Soften</string> + <string name="text_makeup_trimface">Trimface</string> + <string name="text_makeup_bigeye">Bigeye</string> + </resources> diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index f00117702..67fd3fe32 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -84,6 +84,7 @@ import com.android.gallery3d.filtershow.editors.EditorColorBorder; import com.android.gallery3d.filtershow.editors.EditorCrop; import com.android.gallery3d.filtershow.editors.EditorDraw; import com.android.gallery3d.filtershow.editors.EditorGrad; +import com.android.gallery3d.filtershow.editors.EditorMakeup; import com.android.gallery3d.filtershow.editors.EditorManager; import com.android.gallery3d.filtershow.editors.EditorMirror; import com.android.gallery3d.filtershow.editors.EditorPanel; @@ -100,6 +101,7 @@ import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation; import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation; import com.android.gallery3d.filtershow.filters.FiltersManager; import com.android.gallery3d.filtershow.filters.ImageFilter; +import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter; import com.android.gallery3d.filtershow.history.HistoryItem; import com.android.gallery3d.filtershow.history.HistoryManager; import com.android.gallery3d.filtershow.imageshow.ImageShow; @@ -120,6 +122,7 @@ import com.android.gallery3d.filtershow.ui.ExportDialog; import com.android.gallery3d.filtershow.ui.FramedTextButton; import com.android.gallery3d.util.GalleryUtils; import com.android.photos.data.GalleryBitmapPool; +import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine; import java.io.File; import java.io.FileDescriptor; @@ -178,6 +181,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private CategoryAdapter mCategoryGeometryAdapter = null; private CategoryAdapter mCategoryFiltersAdapter = null; private CategoryAdapter mCategoryVersionsAdapter = null; + private CategoryAdapter mCategoryMakeupAdapter = null; private int mCurrentPanel = MainPanel.LOOKS; private Vector<FilterUserPresetRepresentation> mVersions = new Vector<FilterUserPresetRepresentation>(); @@ -380,6 +384,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL fillTools(); fillEffects(); fillVersions(); + fillMakeup(); } public void setupStatePanel() { @@ -468,6 +473,25 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + private void fillMakeup() { + if(!SimpleMakeupImageFilter.HAS_TS_MAKEUP) { + return; + } + + FiltersManager filtersManager = FiltersManager.getManager(); + ArrayList<FilterRepresentation> makeups = filtersManager.getMakeup(); + if (mCategoryMakeupAdapter != null) { + mCategoryMakeupAdapter.clear(); + } + mCategoryMakeupAdapter = new CategoryAdapter(this); + for (FilterRepresentation makeup : makeups) { + if (makeup.getTextId() != 0) { + makeup.setName(getString(makeup.getTextId())); + } + mCategoryMakeupAdapter.add(new Action(this, makeup)); + } + } + private void fillTools() { FiltersManager filtersManager = FiltersManager.getManager(); ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools(); @@ -529,6 +553,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mEditorPlaceHolder.addEditor(new EditorMirror()); mEditorPlaceHolder.addEditor(new EditorRotate()); mEditorPlaceHolder.addEditor(new EditorStraighten()); + mEditorPlaceHolder.addEditor(new EditorMakeup()); } private void setDefaultValues() { @@ -583,6 +608,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL return mCategoryBordersAdapter; } + public CategoryAdapter getCategoryMakeupAdapter() { + return mCategoryMakeupAdapter; + } + public CategoryAdapter getCategoryGeometryAdapter() { return mCategoryGeometryAdapter; } @@ -736,16 +765,16 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL MasterImage master = MasterImage.getImage(); Rect originalBounds = master.getOriginalBounds(); if (master.supportsHighRes()) { - int highresPreviewSize = master.getOriginalBitmapLarge().getWidth() * 2; - if (highresPreviewSize > originalBounds.width()) { - highresPreviewSize = originalBounds.width(); - } + int highresPreviewSize = Math.min(MasterImage.MAX_BITMAP_DIM, getScreenImageSize()); + Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.doInBackground(): after, highresPreviewSize is " + highresPreviewSize); Rect bounds = new Rect(); Bitmap originalHires = ImageLoader.loadOrientedConstrainedBitmap(master.getUri(), master.getActivity(), highresPreviewSize, master.getOrientation(), bounds); master.setOriginalBounds(bounds); master.setOriginalBitmapHighres(originalHires); + Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.doInBackground(): originalHires.WH is (" + originalHires.getWidth() + + ", " + originalHires.getHeight() +"), bounds is " + bounds.toString()); mBoundService.setOriginalBitmapHighres(originalHires); master.warnListeners(); } @@ -758,6 +787,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL if (highresBitmap != null) { float highResPreviewScale = (float) highresBitmap.getWidth() / (float) MasterImage.getImage().getOriginalBounds().width(); + Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.onPostExecute(): highResPreviewScale is " + highResPreviewScale); mBoundService.setHighresPreviewScaleFactor(highResPreviewScale); } MasterImage.getImage().warnListeners(); @@ -785,6 +815,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public LoadBitmapTask() { mBitmapSize = getScreenImageSize(); + Log.d(LOGTAG, "FilterShowActivity.LoadBtimapTask(): mBitmapSize is " + mBitmapSize); } @Override @@ -841,6 +872,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL float previewScale = (float) largeBitmap.getWidth() / (float) MasterImage.getImage().getOriginalBounds().width(); + Log.d(LOGTAG, "FilterShowActivity.LoadBitmapTask.onPostExecute(): previewScale is " + previewScale); mBoundService.setPreviewScaleFactor(previewScale); if (!mShowingTinyPlanet) { mCategoryFiltersAdapter.removeTinyPlanet(); @@ -849,6 +881,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mCategoryBordersAdapter.imageLoaded(); mCategoryGeometryAdapter.imageLoaded(); mCategoryFiltersAdapter.imageLoaded(); + if(mCategoryMakeupAdapter != null) { + mCategoryMakeupAdapter.imageLoaded(); + } mLoadBitmapTask = null; MasterImage.getImage().warnListeners(); @@ -1022,6 +1057,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL if (mShareActionProvider != null) { mShareActionProvider.setOnShareTargetSelectedListener(this); } + if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) { + MakeupEngine.getMakeupObj().setContext(getBaseContext()); + } } @Override diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java index 09f02dd37..50f0e9436 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java @@ -79,6 +79,9 @@ public class CategoryAdapter extends ArrayAdapter<Action> { mSelectedPosition = 0; mAddButtonText = getContext().getString(R.string.filtershow_add_button_looks); } +// if (category == MainPanel.MAKEUP) { +// mSelectedPosition = 0; +// } if (category == MainPanel.BORDERS) { mSelectedPosition = 0; } diff --git a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java index fb51bf5ad..66b352ffb 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java @@ -29,7 +29,7 @@ import android.widget.ListView; import android.widget.TextView; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.FilterShowActivity; - +import android.util.Log; public class CategoryPanel extends Fragment implements View.OnClickListener { public static final String FRAGMENT_TAG = "CategoryPanel"; @@ -89,6 +89,13 @@ public class CategoryPanel extends Fragment implements View.OnClickListener { } break; } + case MainPanel.MAKEUP: { + mAdapter = activity.getCategoryMakeupAdapter(); + if (mAdapter != null) { + mAdapter.initializeSelection(MainPanel.MAKEUP); + } + break; + } } updateAddButtonVisibility(); } @@ -148,7 +155,7 @@ public class CategoryPanel extends Fragment implements View.OnClickListener { return; } FilterShowActivity activity = (FilterShowActivity) getActivity(); - if (activity.isShowingImageStatePanel() && mAdapter.showAddButton()) { + if (activity.isShowingImageStatePanel() && mAdapter != null && mAdapter.showAddButton()) { mAddButton.setVisibility(View.VISIBLE); if (mAdapter != null) { mAddButton.setText(mAdapter.getAddButtonText()); diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index 082bf143a..1dbe42083 100644 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -24,9 +24,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.LinearLayout; - +import android.util.Log; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.FilterShowActivity; +import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter; import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.state.StatePanel; @@ -39,6 +40,7 @@ public class MainPanel extends Fragment { private ImageButton bordersButton; private ImageButton geometryButton; private ImageButton filtersButton; + private ImageButton makeupButton; public static final String FRAGMENT_TAG = "MainPanel"; public static final int LOOKS = 0; @@ -46,6 +48,7 @@ public class MainPanel extends Fragment { public static final int GEOMETRY = 2; public static final int FILTERS = 3; public static final int VERSIONS = 4; + public static final int MAKEUP = 5; private int mCurrentSelected = -1; private int mPreviousToggleVersions = -1; @@ -72,6 +75,12 @@ public class MainPanel extends Fragment { filtersButton.setSelected(value); break; } + case MAKEUP: { + if(makeupButton != null) { + makeupButton.setSelected(value); + } + break; + } } } @@ -97,6 +106,19 @@ public class MainPanel extends Fragment { bordersButton = (ImageButton) mMainView.findViewById(R.id.borderButton); geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton); filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton); + if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) { + makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton); + makeupButton.setVisibility(View.VISIBLE); + } + + if(makeupButton != null) { + makeupButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showPanel(MAKEUP); + } + }); + } looksButton.setOnClickListener(new View.OnClickListener() { @Override @@ -173,6 +195,19 @@ public class MainPanel extends Fragment { selection(mCurrentSelected, true); } + public void loadCategoryMakeupPanel() { + if (makeupButton == null || mCurrentSelected == MAKEUP) { + return; + } + boolean fromRight = isRightAnimation(MAKEUP); + selection(mCurrentSelected, false); + CategoryPanel categoryPanel = new CategoryPanel(); + categoryPanel.setAdapter(MAKEUP); + setCategoryFragment(categoryPanel, fromRight); + mCurrentSelected = MAKEUP; + selection(mCurrentSelected, true); + } + public void loadCategoryGeometryPanel() { if (mCurrentSelected == GEOMETRY) { return; @@ -239,6 +274,10 @@ public class MainPanel extends Fragment { loadCategoryVersionsPanel(); break; } + case MAKEUP: { + loadCategoryMakeupPanel(); + break; + } } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java index a60b6722c..0581835f4 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -50,6 +51,7 @@ public class EditorPanel extends Fragment { super.onAttach(activity); FilterShowActivity filterShowActivity = (FilterShowActivity) activity; mEditor = filterShowActivity.getEditor(mEditorID); + Log.d(LOGTAG, "EditorPanle.onAttach(): mEditorID is " + mEditorID + ", mEditor is " + mEditor); } public void cancelCurrentFilter() { 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/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/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java index 2022ffd7e..d7c2eb4f8 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java @@ -288,7 +288,7 @@ public class ImageShow extends View implements OnGestureListener, drawImageAndAnimate(canvas, highresPreview); } - drawHighresImage(canvas, fullHighres); +// drawHighresImage(canvas, fullHighres); drawCompareImage(canvas, getGeometryOnlyImage()); canvas.restore(); diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java index 4b43d7672..5e27f4213 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java +++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java @@ -25,6 +25,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; +import android.util.Log; import com.android.gallery3d.exif.ExifTag; import com.android.gallery3d.filtershow.FilterShowActivity; @@ -211,6 +212,9 @@ public class MasterImage implements RenderingRequestCaller { int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / mOriginalBitmapLarge .getWidth()); mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true); + Log.d(LOGTAG, "MasterImage.loadBitmap(): OriginalBitmapLarge.WH is (" + mOriginalBitmapLarge.getWidth() + ", " + + mOriginalBitmapLarge.getHeight() + "), OriginalBitmapSmall.WH is (" + sw + ", " + sh + "), originalBounds is " + + originalBounds.toString()); mZoomOrientation = mOrientation; warnListeners(); return true; diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java index e5736d43c..e334e8798 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java +++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java @@ -304,12 +304,14 @@ public class ProcessingService extends Service { filtersManager.addBorders(this); filtersManager.addTools(this); filtersManager.addEffects(); + filtersManager.addMakeups(this); FiltersManager highresFiltersManager = FiltersManager.getHighresManager(); highresFiltersManager.addLooks(this); highresFiltersManager.addBorders(this); highresFiltersManager.addTools(this); highresFiltersManager.addEffects(); +// highresFiltersManager.addMakeups(this); } private void tearDownPipeline() { |