使用get Rotation的原生相机

时间:2015-06-23 18:19:35

标签: android native

我很多东西在IMAGE_CAPTURE之后找到相机旋转(角度-0,90,180,270)但没有获得正确的旋转度。我使用的是 ExifInterface 类,但是获得了“0”或“1”。

    //Image Capture 
    final static int CAMERA_OUTPUT = 0; 
    File file;     


    @Override
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.camerapreview); 
    Intent i = new Intent("android.media.action.IMAGE_CAPTURE");
file = new File(Environment.getExternalStorageDirectory().getPath() + "/Images/" + image_name + ".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    startActivityForResult(i, CAMERA_RESULT); 

    } 



protected void onActivityResult(int requestCode, int resultCode, Intent intent) { 
    super.onActivityResult(requestCode, resultCode, intent); 

    if (resultCode == RESULT_OK) 
    { 
    ExifInterface ei = new ExifInterface(file.getAbsoultePath());
    int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    //In Log getting 0 or 1 issue
   Log.d("tag","Rotation is "+orientation);
    }
    }

请先了解如何在拍摄图像后获得旋转度。

0 个答案:

没有答案