联网获取图片, 保存用户的图像 bitmap

// 保存用户头像

// jsonObject.getString("portrait");图片的地址

       // 保存用户的头像地址 Constat
       public static Bitmap userIc = null;


      Constant.userIc = Net.getBitmap(jsonObject.getString("portrait"));

/**
	 * 联网获取图片
	 * 
	 * @param s
	 *            传入的图片路径
	 * @return
	 */
	public static Bitmap getBitmap(String s) {
		Bitmap bitmap = null;
		try {
			URL url = new URL(s);
			BitmapFactory.Options opt = new BitmapFactory.Options();
			opt.inPreferredConfig = Bitmap.Config.RGB_565;// 表示16位位图
			// opt.inSampleSize = 2;
			opt.inInputShareable = true;
			opt.inPurgeable = true;// 设置图片可以被回收
			bitmap = BitmapFactory.decodeStream(url.openStream(), null, opt);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return bitmap;
	}
原文地址:https://www.cnblogs.com/childhooding/p/4470859.html