码迷,mamicode.com
首页 > 移动开发 > 详细

Android 将图片网址url转化为bitmap

时间:2017-11-21 14:30:53      阅读:744      评论:0      收藏:0      [点我收藏+]

标签:tin   nbsp   nal   tor   style   decode   ide   err   nec   

public Bitmap returnBitMap(final String url){

    new Thread(new Runnable() {
        @Override
        public void run() {
                  URL imageurl = null;

    try {
        imageurl = new URL(url);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    try {
        HttpURLConnection conn = (HttpURLConnection)imageurl.openConnection();
        conn.setDoInput(true);
        conn.connect();
        InputStream is = conn.getInputStream();
        bitmap = BitmapFactory.decodeStream(is);
        is.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
        }
    }).start();

    return bitmap;
}

 

Android 将图片网址url转化为bitmap

标签:tin   nbsp   nal   tor   style   decode   ide   err   nec   

原文地址:http://www.cnblogs.com/zhujiabin/p/7872396.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!