如何在kotlin android中将base64字符串转换为图像 [英] How to convert base64 string into image in kotlin android
本文介绍了如何在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)
这篇关于如何在kotlin android中将base64字符串转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文