我不知道,爲什麼我從BitmapFactory.decodeFile(String imagePath)方法中獲取null。 imagePath是完美的。代碼在這裏。BitmapFactory.decodeFile(String imagePath)返回null連圖像存在
public static byte[] imageToByteArray(String imagePath){
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG , 100 , byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
}
imaagePath是。這裏我使用谷歌的地方API和ImagePath的是谷歌的網絡服務定圖像的位置的互聯網具體路徑。
http://stackoverflow.com/questions/11372831/android-bitmapfactory-decodestream-doesnt-load-https-url-on-emulator –