0
我使用下面的代码我的位图图像编码为一个byte [],然后为一个字符串,但在其编码为字节的时间[]它说无法编码..无法转换图像位图的ByteArray
Bitmap bm = BitmapFactory.decodeFile(path);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
(bm).compress(Bitmap.CompressFormat.JPEG, 100, stream);
bm.recycle();
byte[] byteFormat = stream.toByteArray();
String encodedImage = Base64.encodeToString(byteFormat, Base64.NO_WRAP);
该应用程序工作正常,但我卡在这里。建议问题。
这里,检查接受的答案:http://stackoverflow.com/questions/4830711/how-to-convert-a-image- into-base64-string – resw67
'将它编码为byte []'你正在将位图压缩为一个jpg字节数组。之后,base64将字节编码为一个字符串。目前还不清楚你正在谈论哪个行动/陈述。 – greenapps
@greenapps,我真正想要做的是将图像存储为字节数组,然后将其转换为字符串,然后我将存储该字符串,当我想要使用图像时,我会将该字符串转换为字节数组然后在一些imageview中显示图像。 –