我遇到了CameraX屏幕旋转支持的问题。
纵向: 横向: 变换代码:
纵向: 横向: 变换代码:
private void updateTransform() {
Log.d(TAG, "updateTransform: ");
Matrix matrix = new Matrix();
float centerX = cameraViewTextureV.getWidth() / 2f;
float centerY = cameraViewTextureV.getHeight() / 2f;
switch (cameraViewTextureV.getDisplay().getRotation()) {
case Surface.ROTATION_0:
rotation = 0;
break;
case Surface.ROTATION_90:
rotation = 90;
break;
case Surface.ROTATION_180:
rotation = 180;
break;
case Surface.ROTATION_270:
rotation = 270;
break;
default:
break;
}
matrix.postRotate((float) -rotation, centerX, centerY);
cameraViewTextureV.setTransform(matrix);
}
所以,正如您在图片中看到的那样,相机支持屏幕旋转时不正确... 当屏幕旋转时,我调用updateTransform
方法... 我从Android开发者网站上的CameraX官方指南中获取了此代码。
非常感谢任何修复建议。祝您有一个愉快的一天!