natario1/CameraView

How Flip camera horizontally

Child0fTheSun opened this issue · 2 comments

I use snapshots to take photos and videos and would like to be able to flip the camera horizontally. I tried to do it with filters, but without success. Anyone could give me a hint?

Im using version 2.7.2

Use custom filter

public class CameraFlipEffect extends BaseFilter {
    @Override
    protected void onPreDraw(long timestampUs, @NonNull float[] transformMatrix) {
        android.opengl.Matrix.rotateM(transformMatrix, 0, 180, 0, 1, 0);
        android.opengl.Matrix.translateM(transformMatrix, 0, -1, 0, -1);
        super.onPreDraw(timestampUs, transformMatrix);
    }

    @NonNull
    @Override
    public String getFragmentShader() {
        return createDefaultFragmentShader();
    }
}