2013-06-29 159 views
2

我正在使用相機意圖拍照。但是我在Imageview上看到了很大的圖像。 我的問題是 -Android相機意圖ACTION_IMAGE_CAPTURE對圖像造成90度方向

1.I want full sized image (Which I am getting using putExtra(),) 
2.But due to this My imageview size is increasing. 
3. Main problem is , Image captured is 90 degree roteted.. 

我的代碼如下。

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
       try 
       { 
        // place where to store camera taken picture 
        tempPhoto = createTemporaryFile("picture", ".png"); 
        tempPhoto.delete(); 
       } 
       catch(Exception e) 
       { 

        return ; 
       } 
       mImageUri = Uri.fromFile(tempPhoto); 
       cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); 
       startActivityForResult(cameraIntent, 6); 

和onActivityResult ---

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

     ContentResolver cr = getApplicationContext().getContentResolver(); 

     Bitmap photo=null; 
     if (resultCode == RESULT_OK) { 

      try { 
       photo = android.provider.MediaStore.Images.Media.getBitmap(cr, Uri.fromFile(tempPhoto)); 
      } catch (FileNotFoundException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (Exception e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 


       ImageView imageView = (ImageView)this.findViewById(R.id.imageView1); 

       imageView.setImageBitmap(photo); 

       } 

我試圖用 //Bitmap photo = (Bitmap) data.getExtras().get("data");
這導致空指針異常.. 如何解決該問題得到小圖像?

回答

2

我得到了我的問題的答案。

1.To通過相機獲得全尺寸的圖像,使用

mImageUri = Uri.fromFile(tempPhoto); 
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); 

//tempPhoto is file location here you are storing camera photo in a temp file. 
  1. 保持ImageView大小使用android:adjustViewBounds="true"

  2. 圖像定向使用ExifOrientaion Pleae檢查此鏈接爲ExifOrientaionhttp://developer.android.com/reference/android/media/ExifInterface.html

相關問題