Android:网络图片Url 转 Bitmap
2015-02-09 15:37
225 查看
注意:该方法必须要在子线程中调用,因为涉及网络请求
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 根据网络图片URL转Bitmap对象
- Android 根据网络图片URL转Bitmap对象
- android开发-通过HttpURLConnection获取网络内容,Bitmap把二进制格式的图片转为位图
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- android HttpURLConnection编程详解,获取网络图片,html代码查看
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- android下载网络图片,BitmapFactory创建bitmap
- android:图片处理(本地uri图片显示,本地uri转为bitmap和网络uri转为bitmap显示,制作缩略图)
- Android中如何根据图片url路径来获取网络图片
- android获取网络图片的用法 BitmapFactory.decodeByteArray
- Android--消息机制--handler--getImageFromUrl--网络上获取图片
- Android 使用URL读取网络图片
- Android HttpURLConnection(Get,Post方式)进行网络通信 获取数据和网络图片
- android 网络图片路径解析和本地图片路径解析的方法 ,base64加密报文解析成bitmap【代码示例】
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
- android 网络编程--URL获取数据/图片
- android 网络编程--URL获取数据/图片
- Android使用HttpURLConnection显示网络图片
- Android通过url获取bitmap图片问题