Android examples for Graphics:Drawable Read
get Drawable Image
//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); }//from w w w. j a v a 2 s . c o m 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; } }