views:

486

answers:

2

Android NinePatch images seem to be standard .png files with extra information. Is there a spec for the format anywhere, as I'd like to be able to implement this on other platforms?

+2  A: 

Just take a look at a 9 patch image in an image viewer. It's simply just a 1px border with black pixels flanking the stretchable areas and transparent marking the static parts.

If you zoom into this image you can see the black border marking the stretchable area:

example

stealthcopter
I was hoping for a documented spec, but I guess that's good enough!
Roddy
I don't think there is any more documentation needed, as it's just a normal png with 1 pixel border.
stealthcopter
I'm not totally clear on how the 1-pixel border is interpreted, particularly with non-contiguous pixel selections, and the difference between top and bottom margins.
Roddy
From my experience each margin pair (top/bottom and left/right) must be identical or it will stop your application from compiling. I.E. selections must be contiguous.This simply splits the image up into the four static corners and the remaining area marked by the black pixels is stretchable.
stealthcopter
A: 

Everything we should ever want to know about PNG is supposed to be here: http://www.libpng.org/pub/png/book/toc.html But I haven't seen any reference to 9-patch.

Mondain
9-patch is a android-specific thing...
Roddy