It's my MySql DB 其ecnoding: -如何將圖像轉換爲android中的字符串?
public String convertBitmapToString(Bitmap bmp) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); //compress to which format you want.
byte[] byte_arr = stream.toByteArray();
String imageStr = Base64.encodeToString(byte_arr, 1);
return imageStr;
}
這是解碼: -
String img=o.toString();
byte[] imageAsBytes = Base64.decode(img.getBytes(), Base64.DEFAULT);
imageView.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length));
謝謝。
可以做到,那麼,什麼是錯的代碼? –
你的意思是?我沒有看到任何問題 – Ghorbanzadeh
什麼是o參考? –