[英]Image to base64
如何將存儲在一個文件夾中的所有圖像轉換為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);
@Ruben JG你必須提供完整的圖像路徑,如sdcard / foldername / filename.PNG / .JPEG
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.