1
사용자 정의 카메라 활동이 생성되었지만 캡처 된 이미지의 방향이 잘못되었습니다. 세로 모드에서 이미지를 캡처하고 90도 회전 한 후 원래 위치에 있지만 가로 방향으로 잘못된 방향으로 이미지 캡처 중입니다.사용자 정의 카메라를 사용하여 캡처 한 이미지의 방향이 잘못되었습니다.
카메라 방향 풍경에서 이미지를 캡처하는 동안. 해결 카메라 미리보기 문제에 대한 세로 모드
카메라 방향을 결과.
public int setPhotoOrientation(Activity activity, int cameraId) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
// do something for phones running an SDK before lollipop
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
return result;
}
비트 맵 방향을 확인하십시오.
private Bitmap imageOreintationValidator(Bitmap bitmap, String path) {
ExifInterface ei;
try {
ei = new ExifInterface(path);
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
bitmap = rotateImage(bitmap, 90);
rot++;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
bitmap = rotateImage(bitmap, 180);
rot++;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
bitmap = rotateImage(bitmap, 270);
rot++;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}