Here you can find the source of getRoundedRectBitmap(Bitmap bitmap, int pixels)
public static Bitmap getRoundedRectBitmap(Bitmap bitmap, int pixels)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; public class Main { public static Bitmap getRoundedRectBitmap(Bitmap bitmap, int pixels) { Bitmap result = null;/*from ww w. ja va 2 s.com*/ try { result = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); int color = 0xFF33B5E5; Paint paint = new Paint(); Rect rect = new Rect(0, 0, 98, 98); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawCircle(50, 50, 50, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); } catch (NullPointerException e) { } catch (OutOfMemoryError o) { } return result; } }