views:

31

answers:

2

I want to download an image from the 'net and set it as the users background. This works great over wi-fi, and some 3G networks, but others (T-Mobile UK, for sure) seem to compress the images before sending them.

This effect is noticeable when using the browser, too - however, if you long press on an image and save it, when viewing in the gallery it is either not compressed at all, or substantially less so. I want to be able to do this in my own app.

I assume it has something to do with the HTTP headers, but of the ones I've modified, none has made a difference.

Can anyone help me out here?

Similar question here http://stackoverflow.com/questions/2183808/android-bitmapfactory-decodebytearray-gives-pixelated-bitmap but is unresolved.

+1  A: 

Have you tried setting a no-cache header? This may work on some networks.

You can also try having the client request the image a second time, this also may skip the compression.

Jonathan
Setting "Pragma: no-cache" and "Cache-Control: no-cache" seem to have done it. Thanks!
blork
A: 

If you have control over the image the user downloads, you may want to put it into a ZIP file including your image, have your code unpack the image, and set it as the background. You would be sure no network apply any degradation this way.

But of course, if you don't have control over the gallery the user can select from, this solution is not applicable...

Kharlos Dominguez
Unfortunately I don't. I did try setting Accept-Encoding: gzip but the server wasn't having any of it.
blork