Android examples for Graphics:Bitmap Crop
circle Crop Bitmap
//package com.book2s; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; public class Main { public static Bitmap circleCrop(Bitmap bitmap) { int size = Math.min(bitmap.getWidth(), bitmap.getHeight()); Bitmap output = Bitmap.createBitmap(size, size, Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, size, size); paint.setAntiAlias(true);/*from www . j a va 2s .com*/ canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); // canvas.drawRoundRect(rectF, roundPx, roundPx, paint); canvas.drawCircle(size / 2, size / 2, size / 2, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); // Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false); // return _bmp; return output; } }