2

カメラインテントを使用して写真を撮っています。しかし、私は 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");
、null ポインター例外が発生します。問題を解決するにはどうすればよいですか?

4

1 に答える 1

2

質問に対する答えが得られました。

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. 画像の向きについては、 http:ExifOrientaion //developer.android.com/reference/android/media/ExifInterface.html のこのリンクを確認してください。ExifOrientaion

于 2013-07-13T07:55:11.023 に答える