android 字符串转bitmap,android – 如何将Base64字符串转换为BitMap图像显示在ImageView?...
生活随笔
收集整理的这篇文章主要介绍了
android 字符串转bitmap,android – 如何将Base64字符串转换为BitMap图像显示在ImageView?...
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
我有一个Base64字符串,表示一个BitMap图像。
我需要将该字符串转换为BitMap图像,以使用它在ImageView在我的Android应用程序
怎么做?
这是我用来将图像转换为base64字符串的代码:
//proceso de transformar la imagen BitMap en un String:
//android:src="c:\logo.png"
Resources r = this.getResources();
Bitmap bm = BitmapFactory.decodeResource(r, R.drawable.logo);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos); //bm is the bitmap object
byte[] b = baos.toByteArray();
//String encodedImage = Base64.encode(b, Base64.DEFAULT);
encodedImage = Base64.encodeBytes(b);
总结
以上是生活随笔为你收集整理的android 字符串转bitmap,android – 如何将Base64字符串转换为BitMap图像显示在ImageView?...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: acs账户是什么意思
- 下一篇: HarmonyOS应用开发者门户,Har