【发布时间】:2015-05-02 09:02:27
【问题描述】:
我需要以 base64 字符串的格式将图像(来自画廊)发送到服务器。我得到图像的路径并将其转换为 base64 字符串。但在服务器上,图像没有完全显示。只有 10% 的图像显示在服务器端。请任何人帮助我如何将图像转换为 base64 字符串。
代码:
filePath = cursor.getString(columnIndex);
Bitmap bitmapOrg = BitmapFactory.decodeFile(filePath);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(CompressFormat.PNG, 100, bao);
byte [] ba = bao.toByteArray();
ba1 =Base64.encodeToString(ba, Base64.DEFAULT);
图像大小:460kb
【问题讨论】:
标签: android base64 android-image android-gallery