Crop And Resize An Image In Android
I am reading an image from disk and displaying it inside of a row in a ListView. The image files are larger than what needs to be displayed inside the ImageView of the rows. Sinc
Solution 1:
You can find out the dimensions of your pictures before loading, cropping and scaling:
BitmapFactory.Optionsoptions=newBitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmapbmo= BitmapFactory.decodeFile(file.getAbsolutePath(), options);
Then load it in sample size:
...
options.inSampleSize = 1/2;
bmo = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
...
= Bitmap.createScaledBitmap(bmo, dW, dH, false);
don't forget to recycle temporary bitmaps or you'll get OOME.
bmo.recycle();
Post a Comment for "Crop And Resize An Image In Android"