//这里也可以是从sd卡上面加载.9图片
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
//确认Bitmap是合法的NinePatch文件
if (NinePatch.isNinePatchChunk(bitmap.getNinePatchChunk())) {
NinePatchDrawable ninePatchDrawable = new NinePatchDrawable(getResources(), bitmap, bitmap.getNinePatchChunk(), new Rect(), null);
}