Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; public class Main { public static Drawable getDrawableImage(Context context, Bitmap source, int row, int col, int rowTotal, int colTotal, float multiple) { Bitmap temp = getBitmap(source, (col - 1) * source.getWidth() / colTotal, (row - 1) * source.getHeight() / rowTotal, source.getWidth() / colTotal, source.getHeight() / rowTotal); if (multiple != 1.0) { Matrix matrix = new Matrix(); matrix.postScale(multiple, multiple); temp = Bitmap.createBitmap(temp, 0, 0, temp.getWidth(), temp.getHeight(), matrix, true); } Drawable d = new BitmapDrawable(context.getResources(), temp); return d; } public static Bitmap getBitmap(Bitmap source, int x, int y, int width, int height) { Bitmap bitmap = Bitmap.createBitmap(source, x, y, width, height); return bitmap; } }