Thursday, 29 August 2013

Decoding a bitmap returns null

Decoding a bitmap returns null

I am trying to decode a bitmap but the function returns null and I don't
know why.
The code:
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
if(requestCode == SELECT_FOTO)
{
Uri imgselect = data.getData();
String imgpath = imgselect.getPath();
File f = new File (imgpath);
Bitmap bm = BitmapFactory.decodeFile(f.getAbsolutePath());
Toast.makeText(Insertarlugar.this, "Bitmap es" + bm,
Toast.LENGTH_LONG).show();
}
The toast indicates me that bm is null. I changed f.getAbsolutePath() for
f.getPath() but the result is the same. Uri imgselect and String imgpath
have values. I don't use SD card and I obtain the bitmap from gallery.
How can I resize the bitmap?
Thanks.

No comments:

Post a Comment