From 9dd6b64327c6a9ebdc3e65523f5dc6373918fb31 Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Mon, 17 Oct 2022 17:49:17 +0800 Subject: [PATCH] Feature: add beauty camera filter --- .../ffmpeg/activity/CameraFilterActivity.kt | 16 +++++++++++++- .../com/frank/ffmpeg/util/FilterTypeUtil.kt | 22 +++++++++++++++++++ app/src/main/res/values-en/strings.xml | 4 ++++ app/src/main/res/values/strings.xml | 4 ++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt diff --git a/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt index 0cdb44b..8c75ed1 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt @@ -2,13 +2,23 @@ package com.frank.ffmpeg.activity import android.os.Bundle import android.view.View +import com.frank.camerafilter.factory.BeautyFilterType import com.frank.camerafilter.widget.BeautyCameraView import com.frank.ffmpeg.R +import com.frank.ffmpeg.util.FilterTypeUtil class CameraFilterActivity : BaseActivity() { private var cameraView: BeautyCameraView ?= null + private var index: Int = 0 + + private val filterType: Array = arrayOf( + BeautyFilterType.NONE, + BeautyFilterType.CRAYON, + BeautyFilterType.SKETCH + ) + override val layoutId: Int get() = R.layout.activity_camera_filter @@ -34,7 +44,11 @@ class CameraFilterActivity : BaseActivity() { showToast("stop recording...") } } else if (view.id == R.id.btn_camera_filter) { - + index++ + if (index >= filterType.size) + index = 0 + cameraView!!.setFilter(filterType[index]) + showToast(getString(FilterTypeUtil.filterTypeToNameId(filterType[index]))) } } diff --git a/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt b/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt new file mode 100644 index 0000000..eab6ae7 --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt @@ -0,0 +1,22 @@ +package com.frank.ffmpeg.util + +import com.frank.camerafilter.factory.BeautyFilterType +import com.frank.ffmpeg.R + +/** + * @author xufulong + * @date 2022/10/17 5:39 下午 + * @desc + */ +object FilterTypeUtil { + + fun filterTypeToNameId(type: BeautyFilterType): Int { + return when (type) { + BeautyFilterType.NONE -> R.string.camera_filter_none + BeautyFilterType.CRAYON -> R.string.camera_filter_crayon + BeautyFilterType.SKETCH -> R.string.camera_filter_sketch + else -> R.string.camera_filter_none + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 6391736..2793304 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -112,4 +112,8 @@ rotate sharpen + None + Crayon + Sketch + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 812096a..6c2b47d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,4 +112,8 @@ 旋转 锐化 + 正常 + 蜡笔 + 素描 +