基于github上面gpuimage库和magiccamera库,
1:改写了OpenGlUtil工具。
2:自定义surfaceview组件,使其可以左右滑动,
关键代码:
package com.view;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by xq on 16/9/26.
*/
public class SwitchGLSurfaceView extends GLSurfaceView{
public static final String TAG = "TAG";
public Switch switchFilter;
float start_x = 0;
float end_x = 0;
public SwitchGLSurfaceView(Context context) {
super(context);
}
public SwitchGLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
start_x = event.getRawX();
end_x = start_x;
break;

本文介绍了如何使用GPUImage库和MagicCamera库在Android上实现相机滤镜效果。通过改写OpenGlUtil工具和自定义SurfaceView组件,实现了左右滑动调整滤镜的功能。同时,文章详细讲解了如何调节相机预览的清晰度,并在拍照后将图片剪切成正方形,边长等于屏幕宽度,以确保图片的适配。项目代码已上传至CameraFilter。

525

被折叠的 条评论
为什么被折叠?



