如何在Kotlin Android中将base64字符串转换为图像
问题描述:
我有一个Base64字符串,表示一个BitMap图像.
I have a Base64 String that represents a BitMap image.
我需要再次将该String转换为BitMap图像,以便在我的Android应用中的ImageView上使用它
I need to transform that String into a BitMap image again to use it on a ImageView in my Android app
该怎么做?
答
您可以使用以下代码进行解码:-
You can use this code to decode: -
val imageBytes = Base64.decode(base64String, Base64.DEFAULT)
val decodedImage = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length)
imageView.setImageBitmap(decodedImage)