Create a new Shader and assign it to Paint. You can use whichever TileMode you like because the shape being drawn isn't larger than the original Bitmap.
fun roundCorners(bmp: Bitmap, radius: Int): Bitmap {
require(radius > 0)
val rounded = Bitmap.createBitmap(bmp.width, bmp.height, Bitmap.Config.ARGB_8888)
Canvas(rounded).drawRoundRect(
0f, 0f, bmp.width.toFloat(), bmp.height.toFloat(),
radius.toFloat(), radius.toFloat(),
Paint(Paint.ANTI_ALIAS_FLAG).apply {
_______________________________________________________________________________
}
)
return rounded
}