Skip to content Skip to sidebar Skip to footer

Captured Image Returns Small Size

I am capturing the image from camera. The captured image's size shows too small when captured. But later if I check in gallery the captured image size shows in MB. I tried debuggin

Solution 1:

You are using the Thumbnail instead of the actual image.

To get the actual image you have to pass Image file uri to the Camera intent as MediaStore.EXTRA_OUTPUT

Sample :

Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);//photoURI - file uri where you want the image to be saved
startActivityForResult(intent, REQUEST_CAMERA);

Refer https://developer.android.com/training/camera/photobasics.html#TaskPath for the required steps and complete code.


To get a scaled Bitmap from file path

inttargetW=800;
    inttargetH=1000;

    // Get the dimensions of the bitmap
    BitmapFactory.OptionsbmOptions=newBitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(imagePath, bmOptions);
    intphotoW= bmOptions.outWidth;
    intphotoH= bmOptions.outHeight;

    intscaleFactor= Math.min(photoW / targetW, photoH / targetH);

    // Decode the image file into a Bitmap
    bmOptions.inJustDecodeBounds = false;
    bmOptions.inSampleSize = scaleFactor;
    bmOptions.inPurgeable = true;

    Bitmapbitmap= BitmapFactory.decodeFile(imagePath, bmOptions);

Post a Comment for "Captured Image Returns Small Size"