Created
July 24, 2018 04:50
-
-
Save iRYO400/81e25804d2e4e142484e3f773a6c2309 to your computer and use it in GitHub Desktop.
A-snippet #3 Drawable to BitmapDescriptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun bitmapDescriptorFromVector(vectorResId: Int, context: Context): BitmapDescriptor { | |
val vectorDrawable = ContextCompat.getDrawable(context, vectorResId) | |
vectorDrawable!!.setBounds(0, 0, vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight) | |
val bitmap = Bitmap.createBitmap(vectorDrawable.intrinsicWidth, vectorDrawable.intrinsicHeight, Bitmap.Config.ARGB_8888) | |
val canvas = Canvas(bitmap) | |
vectorDrawable.draw(canvas) | |
return BitmapDescriptorFactory.fromBitmap(bitmap) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment