Created
October 29, 2018 14:58
-
-
Save gordinmitya/b4752da18de6df93040c77ccd11302f1 to your computer and use it in GitHub Desktop.
This file contains 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 Bitmap loadFromSvg(String name) { | |
File file = new File(getDirectory(), name + ".svg"); | |
if (!file.exists()) return null; | |
Drawable drawable = VectorDrawableCompat.createFromPath(file.getAbsolutePath()); | |
if (drawable == null) return null; | |
Bitmap bitmap = Bitmap.createBitmap( | |
drawable.getIntrinsicWidth(), | |
drawable.getIntrinsicHeight(), | |
Bitmap.Config.ARGB_8888 | |
); | |
Canvas canvas = new Canvas(bitmap); | |
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); | |
drawable.draw(canvas); | |
return bitmap; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment