如何在kotlin android中将base64字符串转换为图像

问题描述:

我有一个代表位图图像的 Base64 字符串.

I have a Base64 String that represents a BitMap image.

我需要再次将该字符串转换为位图图像,以便在我的 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)