If you find this technique interesting, check out GWT's excellent support for automatically generating these at compile-time: just subclass ImageBundle (a simple tag interface) and use annotations to reference the PNGs you need, and the compiler will bundle them into one image like this. At runtime, when you create an Image (from an AbstractImagePrototype that the ImageBundle's methods will give you) all of the work of slicing the specific section is done for you automatically.
And the cherry on top: you can use PNG transparency and the framework will automatically insert the appropriate hack for IE6 in the version of the javascript that those users will get.
And the cherry on top: you can use PNG transparency and the framework will automatically insert the appropriate hack for IE6 in the version of the javascript that those users will get.
It's extremely slick.