Skip to content Skip to sidebar Skip to footer

Bitmap Image Not Displayed In Imageview

I am created a app in which i am allowing user to select image from gallery or take a picture from camera and upload that image to web server.This code works fine.Now in other scre

Solution 1:

You should scale image before display it to ImageView. Once i was facing same problem and scaling of bitmap solve my problem.

Below is code to do so-

Bitmapb= BitmapFactory.decodeByteArray(bitmapProfilePic , 0, bitmapProfilePic .length)
ivProfilePic.setImageBitmap(Bitmap.createScaledBitmap(b, 120, 120, false));

hope this will solve your problem

All the best.

Solution 2:

Got this issue on a KITKAT(API 19) device, but not on device running on LOLLIPOP_MR1(API 22). I guess with API 22 or above no need to do the createScaledBitmap, but for device running on API 19 or below, it will need something like this:

BitmapmyPictureBitmap= BitmapFactory.decodeFile(imagePath);
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) {
    myPictureBitmap = Bitmap.createScaledBitmap(myPictureBitmap, ivMyPicture.getWidth(),ivMyPicture.getHeight(),true);
}
ivMyPicture.setImageBitmap(myPictureBitmap);

Post a Comment for "Bitmap Image Not Displayed In Imageview"