Feature: add filter of color invert

pull/221/head
xufuji456 2 years ago
parent e112ecdeb9
commit 3be79a856c
  1. 3
      CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterFactory.java
  2. 1
      CameraFilter/src/main/java/com/frank/camerafilter/factory/BeautyFilterType.java
  3. 29
      CameraFilter/src/main/java/com/frank/camerafilter/filter/advance/BeautyColorInvertFilter.java
  4. 10
      CameraFilter/src/main/res/raw/color_invert.glsl
  5. 1
      app/src/main/java/com/frank/ffmpeg/activity/CameraFilterActivity.kt
  6. 1
      app/src/main/java/com/frank/ffmpeg/util/FilterTypeUtil.kt
  7. 1
      app/src/main/res/values-en/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

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

@ -3,6 +3,7 @@ package com.frank.camerafilter.factory;
public enum BeautyFilterType {
NONE,
BLUR,
COLOR_INVERT,
HUE,
WHITE_BALANCE,
SKETCH

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

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

@ -16,6 +16,7 @@ class CameraFilterActivity : BaseActivity() {
private val filterType: Array<BeautyFilterType> = arrayOf(
BeautyFilterType.NONE,
BeautyFilterType.BLUR,
BeautyFilterType.COLOR_INVERT,
BeautyFilterType.HUE,
BeautyFilterType.WHITE_BALANCE,
BeautyFilterType.SKETCH

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

@ -117,5 +117,6 @@
<string name="camera_filter_balance">White balance</string>
<string name="camera_filter_sketch">Sketch</string>
<string name="camera_filter_blur">Blur</string>
<string name="camera_filter_invert">Invert</string>
</resources>

@ -117,5 +117,6 @@
<string name="camera_filter_balance">白平衡</string>
<string name="camera_filter_sketch">素描</string>
<string name="camera_filter_blur">模糊</string>
<string name="camera_filter_invert">反相</string>
</resources>

Loading…
Cancel
Save