- 如果base64的文本以类似data:image/png;base64格式开头
- Java
byte[] decode = Base64.decode(imagestr.split(",")[1], Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
- Kotlin
val byte = Base64.decode(data.split(",")[1], Base64.DEFAULT) BitmapFactory.decodeByteArray(byte, 0, byte.size)
- 如果并非以上述格式开头
- Java
byte[] decode = Base64.decode(imagestr, Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
- Kotlin
val byte = Base64.decode(data, Base64.DEFAULT) BitmapFactory.decodeByteArray(byte, 0, byte.size)
网友评论