问题
I am using this line of code for getting the full sized image, i am not setting this image on any view, still this line when executed takes a lot of ram, around 110-120m, any solutions ? I even tried running this code in Backgroung thread using Async Task. The picture resolution is 4008*5344.
Bitmap image = MediaStore.Images.Media.getBitmap(getContentResolver(),Uri.parse(mCurrentPhotoPath));
And the below method given in developers site, gives me Null bitmap.
private void setPic() {
// Get the dimensions of the View
int targetW = mImageView.getWidth();
int targetH = mImageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
mImageView.setImageBitmap(bitmap);
}
来源:https://stackoverflow.com/questions/40578221/getting-full-sized-image-from-camera-memory-issue