How can I convert SVG (Scaleable Vector Graphics) to Bitmap at runtime in Android?
Kindly if possible provide me the exact chunk of code or exact links. I am quite new to Android application development.
Follow the svg-android tutorial to get a PictureDrawable
from your SVG file. Then you need to create a Bitmap
from the size of the PictureDrawable
and give it to a Canvas
. When the Canvas
now draws a Picture
from the PictureDrawable
, the current bitmap you need is drawn(created) at runtime.
PictureDrawable pictureDrawable = svg.createPictureDrawable();
Bitmap bitmap = Bitmap.createBitmap(pictureDrawable.getIntrinsicWidth(), pictureDrawable.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawPicture(pictureDrawable.getPicture());
currentBitmap = bitmap;