Java tutorial
//package com.java2s; import android.graphics.*; public class Main { public static Bitmap toCircleBitmap(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); int r = width < height ? width : height; Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(buffer); Paint paint = new Paint(); paint.setAntiAlias(true); RectF rect = new RectF(0, 0, r, r); canvas.drawCircle(r / 2, r / 2, r / 2, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, null, rect, paint); bitmap.recycle(); return buffer; } }