【发布时间】:2011-01-29 13:28:19
【问题描述】:
我有一个表示位图图像的 Base64 字符串。
我需要再次将该字符串转换为位图图像,以便在我的 Android 应用中的 ImageView 上使用它
怎么做?
这是我用来将图像转换为 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);
【问题讨论】: