Last active
August 10, 2018 04:46
-
-
Save EfeBudak/a9ec13d9d582c6cc7f11156e6775ea47 to your computer and use it in GitHub Desktop.
Vector drawable to bitmap
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
public static BitmapDescriptor generateBitmapDescriptorFromRes( | |
Context context, int resId) { | |
Drawable drawable = ContextCompat.getDrawable(context, resId); | |
drawable.setBounds( | |
0, | |
0, | |
drawable.getIntrinsicWidth(), | |
drawable.getIntrinsicHeight()); | |
Bitmap bitmap = Bitmap.createBitmap( | |
drawable.getIntrinsicWidth(), | |
drawable.getIntrinsicHeight(), | |
Bitmap.Config.ARGB_8888); | |
Canvas canvas = new Canvas(bitmap); | |
drawable.draw(canvas); | |
return BitmapDescriptorFactory.fromBitmap(bitmap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment