Android Camera预览左右上下镜像

SurfaceView预览Camera没找到方法切换左右上下镜像的方法

改用TextureView预览Camera ,可以动态的切换镜像

  • 上下镜像
Matrix matrix = textureView.getTransform(new Matrix());
matrix.setScale(1, -1);                                   //还原   matrix.setScale(1, 1);  
matrix.postTranslate(0, textureView.getHeight());         //还原   matrix.postTranslate(0, 0);
textureView.setTransform(matrix);
  • 左右镜像
Matrix matrix = textureView.getTransform(new Matrix());
matrix.setScale(-1, 1);
int width = textureView.getWidth();
matrix.postTranslate(width, 0);
textureView.setTransform(matrix);

你可能感兴趣的:(Android)