diff --git a/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterFactory.java b/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterFactory.java index 8a87005..1081294 100644 --- a/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterFactory.java +++ b/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterFactory.java @@ -3,6 +3,7 @@ package com.frank.camerafilter.factory; import android.content.Context; import com.frank.camerafilter.filter.advance.BeautyBlurFilter; +import com.frank.camerafilter.filter.advance.BeautyColorInvertFilter; import com.frank.camerafilter.filter.advance.BeautyHueFilter; import com.frank.camerafilter.filter.advance.BeautySketchFilter; import com.frank.camerafilter.filter.BaseFilter; @@ -19,6 +20,8 @@ public class BeautyFilterFactory { return new BeautySketchFilter(context); case BLUR: return new BeautyBlurFilter(context); + case COLOR_INVERT: + return new BeautyColorInvertFilter(context); case HUE: return new BeautyHueFilter(context); case WHITE_BALANCE: diff --git a/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterType.java b/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterType.java index 8be6626..39afcd7 100644 --- a/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterType.java +++ b/CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterType.java @@ -3,6 +3,7 @@ package com.frank.camerafilter.factory; public enum BeautyFilterType { NONE, BLUR, + COLOR_INVERT, HUE, WHITE_BALANCE, SKETCH diff --git a/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautyColorInvertFilter.java b/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautyColorInvertFilter.java new file mode 100644 index 0000000..bdad884 --- /dev/null +++ b/CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautyColorInvertFilter.java @@ -0,0 +1,29 @@ +package com.frank.camerafilter.filter.advance; + +import android.content.Context; +import android.opengl.GLES30; + +import com.frank.camerafilter.R; +import com.frank.camerafilter.filter.BaseFilter; +import com.frank.camerafilter.util.OpenGLUtil; + +public class BeautyColorInvertFilter extends BaseFilter { + + public BeautyColorInvertFilter(Context context) { + super(NORMAL_VERTEX_SHADER, OpenGLUtil.readShaderFromSource(context, R.raw.color_invert)); + } + + protected void onInit() { + super.onInit(); + } + + protected void onInitialized() { + super.onInitialized(); + } + + @Override + public void onInputSizeChanged(int width, int height) { + super.onInputSizeChanged(width, height); + } + +} diff --git a/CameraFilter/src/main/res/raw/color_invert.glsl b/CameraFilter/src/main/res/raw/color_invert.glsl new file mode 100644 index 0000000..0f136b2 --- /dev/null +++ b/CameraFilter/src/main/res/raw/color_invert.glsl @@ -0,0 +1,10 @@ +varying highp vec2 textureCoordinate; + +uniform sampler2D inputImageTexture; + +void main() +{ + lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); + + gl_FragColor = vec4((1.0 - textureColor.rgb), 1.0); +} \ No newline at end of file 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 b3767d2..434523d 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt @@ -16,6 +16,7 @@ class CameraFilterActivity : BaseActivity() { private val filterType: Array = arrayOf( BeautyFilterType.NONE, BeautyFilterType.BLUR, + BeautyFilterType.COLOR_INVERT, BeautyFilterType.HUE, BeautyFilterType.WHITE_BALANCE, BeautyFilterType.SKETCH diff --git a/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt b/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt index 9133e29..2522465 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt +++ b/app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt @@ -14,6 +14,7 @@ object FilterTypeUtil { return when (type) { BeautyFilterType.NONE -> R.string.camera_filter_none BeautyFilterType.BLUR -> R.string.camera_filter_blur + BeautyFilterType.COLOR_INVERT -> R.string.camera_filter_invert BeautyFilterType.HUE -> R.string.camera_filter_hue BeautyFilterType.WHITE_BALANCE -> R.string.camera_filter_balance BeautyFilterType.SKETCH -> R.string.camera_filter_sketch diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 48af113..9a7834c 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -117,5 +117,6 @@ White balance Sketch Blur + Invert diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5a07c5..bd2b1ce 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -117,5 +117,6 @@ 白平衡 素描 模糊 + 反相