Feature: add beauty camera filter

pull/221/head
xufuji456 2 years ago
parent 3ed37dba16
commit 9dd6b64327
  1. 16
      app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt
  2. 22
      app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt
  3. 4
      app/src/main/res/values-en/strings.xml
  4. 4
      app/src/main/res/values/strings.xml

@ -2,13 +2,23 @@ package com.frank.ffmpeg.activity
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import com.frank.camerafilter.factory.BeautyFilterType
import com.frank.camerafilter.widget.BeautyCameraView import com.frank.camerafilter.widget.BeautyCameraView
import com.frank.ffmpeg.R import com.frank.ffmpeg.R
import com.frank.ffmpeg.util.FilterTypeUtil
class CameraFilterActivity : BaseActivity() { class CameraFilterActivity : BaseActivity() {
private var cameraView: BeautyCameraView ?= null private var cameraView: BeautyCameraView ?= null
private var index: Int = 0
private val filterType: Array<BeautyFilterType> = arrayOf(
BeautyFilterType.NONE,
BeautyFilterType.CRAYON,
BeautyFilterType.SKETCH
)
override val layoutId: Int override val layoutId: Int
get() = R.layout.activity_camera_filter get() = R.layout.activity_camera_filter
@ -34,7 +44,11 @@ class CameraFilterActivity : BaseActivity() {
showToast("stop recording...") showToast("stop recording...")
} }
} else if (view.id == R.id.btn_camera_filter) { } 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])))
} }
} }

@ -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
}
}
}

@ -112,4 +112,8 @@
<string name="filter_rotate">rotate</string> <string name="filter_rotate">rotate</string>
<string name="filter_sharpening">sharpen</string> <string name="filter_sharpening">sharpen</string>
<string name="camera_filter_none">None</string>
<string name="camera_filter_crayon">Crayon</string>
<string name="camera_filter_sketch">Sketch</string>
</resources> </resources>

@ -112,4 +112,8 @@
<string name="filter_rotate">旋转</string> <string name="filter_rotate">旋转</string>
<string name="filter_sharpening">锐化</string> <string name="filter_sharpening">锐化</string>
<string name="camera_filter_none">正常</string>
<string name="camera_filter_crayon">蜡笔</string>
<string name="camera_filter_sketch">素描</string>
</resources> </resources>

Loading…
Cancel
Save