Monday, August 13, 2012

[android-developers] JPG corrupted after save and load from external storage

Hi,

I have a jpg with a white background, and after saving and loading it to external storage, it's corrupted. Looks like:


The code:

Save:

    try {
        outStream
= new FileOutputStream(fileUri);
        image
.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
        outStream
.flush();
        outStream
.close();

   
} catch (Exception e) {
       
Log.e("cache", e.getMessage());
        e
.printStackTrace();
   
}

Load:

Bitmap bm = BitmapFactory.decodeFile(fileUri.toString());

What am I doing wrong? Thanks.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment