【发布时间】:2026-02-01 10:40:02
【问题描述】:
我正在尝试将 Base64 字符串图像解码为 Bitmap,但它总是返回 null。
这是我的代码:
public static Bitmap getBitmap(String encode) {
Bitmap bm = null;
try {
byte[] decodedString = Base64.decode(encode, Base64.DEFAULT);
bm = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
} catch (Exception e) {
Log.e(TAG,e.getMessage());
return bm;
}
return bm;
}
【问题讨论】:
-
发布你的代码会有帮助
-
这是我的代码: public static Bitmap getBitmap(String encode) { Bitmap bm = null;尝试 { byte[] decodedString = Base64.decode(encode, Base64.DEFAULT); bm = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); } catch (Exception e) { Log.e(TAG,e.getMessage());返回 bm; } 返回 bm; }