6

I'm developing a mobile web application and I have a home screen with a number of icons on it, so I tried to use a sprite to serve all the images in one swoop.

I noticed, however, that the iphone4 scaled the images in my sprite fairly well (they looked a little dithered), but on my HTC Evo the sprite rendered images look really blocky. I switched to standard images (background:(/image_url/) w/o background-position) and the image looked much better - see this screen shot, where the left image is served using the single image, and the ones to the right of it are served from the sprite (but are the same images in the sprite).

Is there a way to get the Android browser to interpret the sprites better?

Michael Celey
  • 12,645
  • 6
  • 57
  • 62
Simon
  • 1,819
  • 3
  • 18
  • 26

2 Answers2

2

You're hitting the maximum decoded image size barrier in the Android browser. This size limit was upped to something reasonable in 2.3. Try splitting up your sprites into smaller images.

tad
  • 1,383
  • 11
  • 16
  • Interesting, do you know what the max size is in Froyo? This isn't device dependent, is it? – Simon Apr 28 '11 at 02:31
  • I dug through the relevant source code here: http://www.sephidev.net/external/webkit/WebCore/platform/graphics/android/ImageSourceAndroid.cpp . Size limit is 8*1024*1024 bytes (about 8M) on "large memory devices" (>256M), and 2*1024*1024 bytes (about 2M) on "low memory devices". Note that this is the **decompressed** size, which you can approximate by saving your source images as bitmaps and checking the filesize. – tad Jun 17 '11 at 20:52
  • @tad Thanks again for your followup comment with the pointer to the webkit src file where that c macro is used - saved me heaps of time searching around trying to fix that. – Maks Mar 31 '13 at 04:10
0

This is just a guess but, which one are you using? Your operator or wifi connection? Some operators do compress images over certain size.

nLL
  • 5,662
  • 11
  • 52
  • 87