Android 网络图片Url 转 Bitmap
2017-04-28 00:33
429 查看
注意:该方法必须要在子线程中调用,因为涉及网络请求
public Bitmap getBitmap(String url) { Bitmap bm = null; try { URL iconUrl = new URL(url); URLConnection conn = iconUrl.openConnection(); HttpURLConnection http = (HttpURLConnection) conn; int length = http.getContentLength(); conn.connect(); // 获得图像的字符流 InputStream is = conn.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is, length); bm = BitmapFactory.decodeStream(bis); bis.close(); is.close();// 关闭流 } catch (Exception e) { e.printStackTrace(); } return bm; }
相关文章推荐
- Android 根据网络图片URL转Bitmap对象
- android开发-通过HttpURLConnection获取网络内容,Bitmap把二进制格式的图片转为位图
- Android 根据网络图片URL转Bitmap对象
- Android:网络图片Url 转 Bitmap
- android 网络编程--URL获取数据/图片
- android下载网络图片,BitmapFactory创建bitmap
- Android HttpURLConnection(Get,Post方式)进行网络通信 获取数据和网络图片
- Android中如何根据图片url路径来获取网络图片
- 【转】android:网络图片转为bitmap 保存至SD卡中
- android 读取本地或网络图片,转换为Bitmap 并保存本地中
- android 简单网络图片查看器 HttpURLConnection
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- android:图片处理(本地uri图片显示,本地uri转为bitmap和网络uri转为bitmap显示,制作缩略图)
- Android - HttpURLConnection下载网络文件,加载网络图片
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- android 网络图片路径解析和本地图片路径解析的方法 ,base64加密报文解析成bitmap【代码示例】
- Android 使用URL读取网络图片
- 网络图片url->bitmap
- android 使用URL读取网络图片简单示例
- android httpUrlConnection 方式从网络上面下载图片