0

I am requesting an image from the Gallery for my app.I find that images from the Download folder are not being displayed in my app.From the LogCat I have found that the image has been obtained by the Activity:

D/BadgerListActivity(1984): Uri is: content://media/external/images/media/3080 and the pathName: /storage/emulated/0/Download/2801.jpg
D/ImagePreviewActivity(1984): pathName: /storage/emulated/0/Download/2801.jpg
W/OpenGLRenderer(1984): Bitmap too large to be uploaded into a texture (1905x2481, max=2048x2048)

How do I programatically find the maximum height and width of the image that can be displayed in the ImageView?

vamsiampolu
  • 5,890
  • 16
  • 76
  • 171

1 Answers1

2

scale down the image and try

ImageView iv  = (ImageView)ImagePreviewActivity.findViewById(R.id.photo);
Bitmap bitmap  = new BitmapDrawable(context.getResources() , w.photo.getAbsolutePath()).getBitmap();
int size = (int) ( bitmap .getHeight() * (512.0 / bitmap .getWidth()) );
Bitmap scaled = Bitmap.createScaledBitmap(bitmap , 512, size, true);
iv.setImageBitmap(scaled);

Source

Community
  • 1
  • 1
Kalai.G
  • 1,690
  • 13
  • 22