private Bitmap get_ninepatch(int id,int x, int y, Context context){
// id is a resource id for a valid ninepatch
Bitmap bitmap = BitmapFactory.decodeResource(
context.getResources(), id);
byte[] chunk = bitmap.getNinePatchChunk();
NinePatchDrawable np_drawable = new NinePatchDrawable(bitmap,
chunk, new Rect(), null);
np_drawable.setBounds(0, 0,x, y);
Bitmap output_bitmap = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output_bitmap);
np_drawable.draw(canvas);
return output_bitmap;
}