Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Bitmap.Config; public class Main { public static Bitmap cutMatrixBitmap(Bitmap src, float scale) { int srcW = src.getWidth(); int srcH = src.getHeight(); int matrixW = srcW; int matrixH = srcH; matrixW = (int) (matrixH * scale); if (matrixW > srcW) { matrixW = srcW; matrixH = (int) (srcW / scale); } int left = (srcW - matrixW) / 2; int top = (srcH - matrixH) / 2; return src == null ? Bitmap.createBitmap(matrixW, matrixH, Config.ARGB_8888) : Bitmap.createBitmap(src, left, top, matrixW, matrixH); } }