Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Created April 15, 2018 08:38
Show Gist options
  • Save EmmanuelGuther/891ab95e9f10477494ea5fdda02aae26 to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/891ab95e9f10477494ea5fdda02aae26 to your computer and use it in GitHub Desktop.
Kotlin function to transform bitmap into roundedBitmap
fun roundedBitmap(bitmap: Bitmap): RoundedBitmapDrawable {
val roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(Resources.getSystem(), bitmap)
roundedBitmapDrawable.isCircular = true
roundedBitmapDrawable.cornerRadius = Math.max(bitmap.width, bitmap.height) / 2.0f
return roundedBitmapDrawable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment