Monday, August 13, 2012

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

Oh, and the fetch method looks like this:

    private InputStream fetch(String urlString) throws MalformedURLException, IOException {
   
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpGet request = new HttpGet(urlString);
        HttpResponse response = httpClient.execute(request);
        return response.getEntity().getContent();
    }

On Monday, August 13, 2012 7:05:01 PM UTC+2, user123 wrote:
What do you mean exactly with original? I'm downloading it from the web, the image in the web has jpg extension.

Maybe it's important, this is the code I instantiate the downloaded bitmap/drawable (which is later saved to the sd card) with:

           InputStream is = fetch(urlString);
           TypedValue typedValue = new TypedValue();

           typedValue.density = TypedValue.DENSITY_DEFAULT;
           Drawable drawable = Drawable.createFromResourceStream(null, typedValue, new FlushedInputStream(is), "src");

On Monday, August 13, 2012 6:41:31 PM UTC+2, Harri Smått wrote:

On Aug 13, 2012, at 7:31 PM, user123 <ivans...@gmail.com> wrote:

> What am I doing wrong? Thanks.

This is a long shot but are you sure original image is JPG and not a PNG with alpha channel? Alpha could cause some unexpected behaviour once storing image as JPG.

--
H

--
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