[英]How do i get bitmap image from inputstream(base64 String) in android?
如何在Android中從InputStream(base64 String)
獲取位圖圖像?
下面是我的代碼:
protected Bitmap doInBackground(Void... params) {
Bitmap image;
URL url1 = null;
try {
url1 = new URL("http://sunnyfacemash.atwebpages.com/get.php"); // url
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
image = BitmapFactory.decodeStream(url1.openConnection().getInputStream());
return image;
} catch (IOException e) {
image = null;
e.printStackTrace();
}
return image;
}
將流下載到字符串,然后在其上使用Base64.decode
其提供給BitmapFactory
。
將ByteArrayInputStream
用於工廠
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.