| Issue 53: | Optimize sprite positions | |
| 2 people starred this issue and may be notified of changes. | Back to list |
I've noticed that a lot of times spriting the images, while reducing the number of round trips (which is great), will create a file that's ultimately larger (in bytes) than the original images. This behavior could be reduced by optimizing the way the sprite image is constructed to take advantage of empty space. For example, when you have one image to be sprited that's 100x20px and 5 that are 15x20px you could create a sprite image that has the 5 smaller images directly beneath the larger file. Instead of this: ___________ |xxxxxxxxx| |x | |x | |x | |x | |x | ___________ You could have this: ___________ |xxxxxxxxx| |x x x x x| ___________ I know that this logic is much more difficult, but would result in much smaller file sizes because of a reduction in wasted space.
Sep 21, 2009
Project Member
#1
stevesou...@gmail.com
Sep 21, 2009
Steve, anyway it will be very useful. And algorithm can be quite simple: just sort images by x*x+y*y, then try to add to the Sprite one-by-one, checking for 'filled' pixels.
Oct 14, 2010
It turns out that the memory implications here are pretty significant, as Steve mentions here: http://www.stevesouders.com/blog/2009/09/21/spriteme-part-3/ |