I have SVG file encoded as base64, and I want to show the image with ImageView. This is what I tried:
// imageBase64 is string that represents the SVG image encoded as base64
byte[] decodedString = Base64.decode(imageBase64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
but decodedByte always returned null.
PS:
- This code works with jpeg images.
- If the base64 string contains the base64 prefix ("data:image/svg+xml;base64," or "data:image/jpeg;base64,) the decodedByte always returned null too
- The base64 string is correct (its works good in HTML and other base64 online tools)