Question

I am using camera intent to take photo. But I am getting to big image on Imageview. My problem is--

 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..

My code is as follow.

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);

and in 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);

                }

I am trying to get small image using //Bitmap photo = (Bitmap) data.getExtras().get("data");
this causing null pointer Exception.. How to resolve the problem?

Was it helpful?

Solution

I got the answer to my questions.

1.To get a full sized image through camera, Use

 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. to maintain ImageView size use android:adjustViewBounds="true"

  2. for image orientation use ExifOrientaion Pleae check this link for ExifOrientaion http://developer.android.com/reference/android/media/ExifInterface.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top