You can do that using Android PorterDuffMode Here is the code
private fun crop(bitmapImage: Bitmap): Bitmap {
val bitmap = Bitmap.createBitmap(
bitmapImage.width,
bitmapImage.height,
Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmap)
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
canvas.drawCircle(100.0f, 100.0f, 50.0f, paint)
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)
canvas.drawBitmap(bitmapImage, 0.0f, 0.0f, paint)
return bitmap
}
you can change the circle pivot and radius to achieve your result, If you pass the bitmap of the image, it will return the bitmap and you can save to file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.