android 字符串转bitmap,android – 如何将Base64字符串转换为BitMap图像显示在ImageView?...
我有一個Base64字符串,表示一個BitMap圖像。
我需要將該字符串轉(zhuǎn)換為BitMap圖像,以使用它在ImageView在我的Android應(yīng)用程序
怎么做?
這是我用來將圖像轉(zhuǎn)換為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);
總結(jié)
以上是生活随笔為你收集整理的android 字符串转bitmap,android – 如何将Base64字符串转换为BitMap图像显示在ImageView?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: acs账户是什么意思
- 下一篇: HarmonyOS应用开发者门户,Har