【问题标题】:Android Camera Intent ACTION_IMAGE_CAPTURE causing 90 degree orientation to imageAndroid Camera Intent ACTION_IMAGE_CAPTURE 导致图像呈 90 度方向
【发布时间】:2013-06-29 05:28:39
【问题描述】:

我正在使用相机意图拍照。但我正在 Imageview 上获得大图像。 我的问题是——

 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");
这导致空指针异常.. 如何解决问题?

【问题讨论】:

    标签: android android-camera-intent


    【解决方案1】:

    我的问题得到了答案。

    1.要通过相机获得全尺寸图像,请使用

     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请查看此链接以获取ExifOrientaionhttp://developer.android.com/reference/android/media/ExifInterface.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多