2013-08-30 2 views
0

이것은 Portrait 모드의 내 카메라 활동입니다. 장치를 회전시키고 카메라가 함께 회전합니다.회전 장치가 이미지 방향을 바꿉니 까?

Camera

이 내 화상 거꾸로 ImageView에 표시된다 Activity초, PictureCallback() 내에서 수신된다. 이미 나는 비슷한 문제를 가지고 0

second

답변

0

ExifInterface하지만 돌아 오는 방향을 시도했다. ExifInterface의 오리엔테이션 0은 정의되지 않음을 의미합니다. 그가 발생하면 내가 미디어 스토어 MediaStore를 물어 ExifInterface 카메라에 대한 0

String[] cols = { MediaStore.Images.Media.ORIENTATION }; 
Cursor cur = context.getContentResolver().query(uri, cols, null, null, null); 
int orientation = 0; 

if (cur != null && cur.moveToFirst()) { 
     orientation = cur.getInt(cur.getColumnIndex(MediaStore.Images.Media.ORIENTATION)); 
} 
+0

여전히 ExifInterface를 사용 점점 방향 = 0; – Mihir

0

설정 반환하는 경우 내 경우에는 항상 올바른 방향을 반환

public static void setCameraDisplayOrientation(Activity activity, 
      int cameraId, android.hardware.Camera camera) { 
     try { 

      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; 
      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; 
      } 
      camera.setDisplayOrientation(result); 
     } catch (Exception e) { 
      // TODO: handle exception 
     } 
    } 

을 때 표시 결과

관련 문제