Android examples for Graphics:Bitmap Round Corner
get Round Corner Bitmap
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; public class Main { public static Bitmap getRoundCornerBitmap(Bitmap mBitmap, float roundPx) { Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Config.ARGB_8888); Canvas mCanvas = new Canvas(bgBitmap); Paint mPaint = new Paint(); Rect mRect = new Rect(0, 0, mBitmap.getWidth(), mBitmap.getHeight()); RectF mRectF = new RectF(mRect); mPaint.setAntiAlias(true);//from ww w . ja v a2s. c o m mCanvas.drawRoundRect(mRectF, roundPx, roundPx, mPaint); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); mCanvas.drawBitmap(mBitmap, mRect, mRect, mPaint); return bgBitmap; } }