轉換在服務器端的base64字符串的圖像,並從應用程序檢索。 然後用下面的字符串的base64解碼成位圖
public static String encodeTobase64(Bitmap image)
{
Bitmap immagex=image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
// Log.e("LOOK", imageEncoded);
return imageEncoded;
}
public static Bitmap decodeBase64(String input)
{
byte[] decodedByte = Base64.decode(input, 0);
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}
謝謝,我想這就是我想要的,可這種轉換在PHP(客戶端)做了什麼?如果我想在我的應用程序中執行緩存操作,會不會很困難? –
你想緩存的Android設備中的圖像 –
是的,我想緩存它,這將是一個問題,如果我遵循你的方式? –