如何将存储在一个文件夹中的所有图像转换为base64数据?在以下代码中,tFotos是存储我所有图像的文件夹。

ArrayList<String> mList = new ArrayList<String>();
Bitmap selectedImage = BitmapFactory.decodeFile( Environment.getExternalStorageDirectory()+"tFotos");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
selectedImage.compress(Bitmap.CompressFormat.JPEG, 100,
                        stream);
byte[] byteArray = stream.toByteArray();
String strBase64 = Base64.encodeToString(byteArray, 0);
mList.add(StrBase64);

最佳答案

@鲁本JG
您必须提供图像的完整路径,例如sdcard / foldername / filename.PNG / .JPEG

关于java - 图片到base64,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22397761/

10-14 20:23
查看更多