skin packer

The Skin class is very convenient to apply skins to GUIs, but the backing texture is manually packed and if changed, the skin JSON has to be rewritten. We now have a class called SkinPacker that takes a directory of individual images and packs them on a single image. It also looks at the top and left edges of each image before packing. If it finds magenta pixels, it uses them as the split points for a nine patch. If it doesn’t find any, it uses the whole image as a region. The tool outputs the JSON for the skin with all the proper coordinates for the packed images.

4 thoughts on “skin packer

  1. This is reeeeeaal coool! I’m just right now at the point where I’ll use this tool, where as I had feared before the fiddling with those files and images and defining the areas myself – thanks a lot!
    However, I wonder a little bit why you don’t take the same aproach like Google with Android. This would allow to reuse 9-Patches from previous projects, and even they’r 9-Patch designer! Maybe you could add that or reconsider your solution (sorry to even ask you that, I’m a developer myself, so I really don’t want to frustrate you!).
    Here it is: http://developer.android.com/guide/developing/tools/draw9patch.html

    But again, thanks a lot!
    Dan

  2. Yeah, their tool is ok. I don’t see huge value in visualizing the nine patch, seeing that you have to create the nine patch art anyway. Detecting repeat errors is nice. I’m not convinced the extra complexity for using the bottom/right for the content/spacing is worth the effort. It only adds value if the content overlaps the side patches, and I’m not sure that happens often. I really don’t think the extra complexity to support having more than one resizable region in each direction is worth it.

    What I do like is using a line of marker pixels to specify the region that resizes. This is more clear than using a single pixel, as I’m doing now. Also, it is probably better to explicitly use a file name like “.9.png” to separate nine patches from simple regions. I will give it some thought and possibly rework the skin packer. Thanks for your input!

  3. Ok, updated SVN. SkinPacker now treats .ong as regions and .9.png files as nine patches in the standard Android format. It can also take an old skin and it preserves all the styles.

  4. hello,I am sorry that i can not run the class of SkinPacker, that reports error as “Error reading file: temp-packed\pack (Absolute)” I do not know why . could you help me and tell me how to use this class? thanks!

Leave a Reply

Your email address will not be published.