I am trying to download an 1mb image file and then save to bitmap to populate an imageview. but shows error
06-13 13:39:48.149: ERROR/AndroidRuntime(1782):
j
I had been through the same issue. Before you set the downloaded bitmap to your ImageView
, you have to compress your bitmap according to the width and height of your ImageView
.
You have to create a scaled bitmap like this,
bm1=Bitmap.createScaledBitmap(bm, 300, 300,true);
imgView.setImageBitmap(bm1);
or Compress your bitmap like this,
OutputStream fOut = null;
File file = new File(strDirectoy,imgname);
fOut = new FileOutputStream(file);
bm1.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());