BitmapFactory.decodeFile

All your problems with Audio, Video and Images.

BitmapFactory.decodeFile

Postby fala70 » Wed Dec 10, 2008 11:04 pm

I did an application that create an image file copied from external memory with follow code:
Bitmap bitmap = Media.getBitmap(getContentResolver(), uri);

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
boolean besito=bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);

String sPath=uri.getPath();
String sNum=sPath.substring(sPath.lastIndexOf("/")+1);
String sFileName =sNum+".jpg";
deleteFile(sFileName);
FileOutputStream fos = openFileOutput(sFileName, MODE_WORLD_WRITEABLE);
fos.write(bytes.toByteArray());
fos.close();

that code save the to internal memory area application and work. Now I 've a problem on BitmapFactory.decodeFile when I try to reload this file, BitmapFactory.decodeFile return null:

ImageView img= (ImageView) findViewById(R.id.imgThumb);
Bitmap bm = BitmapFactory.decodeFile(sFileName);
BitmapDrawable drawable = new BitmapDrawable(bitmap);
img.setImageDrawable(drawable);

somebody can help to understand why BitmapFactory.decodeFile return null ?
thanks
fala70
Freshman
Freshman
 
Posts: 3
Joined: Mon Dec 08, 2008 11:49 am

Top

Postby valibab » Wed Jan 07, 2009 3:28 pm

u have to specify total path in the methos like the one below

bitmap = BitmapFactory.decodeFile("/data/data/myPackage/files/filename");
valibab
Junior Developer
Junior Developer
 
Posts: 19
Joined: Sat Jan 03, 2009 7:11 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests