1. 程式人生 > >QQ分享圖片的方法 Bitmap

QQ分享圖片的方法 Bitmap

/**
 * 根據圖片的url路徑獲得Bitmap物件 * @param url * @return
 */


private Bitmap returnBitmap(String url) {
    URL fileUrl = null;
    Bitmap bitmap = null;
    try {
        fileUrl = new URL(url);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    try {
        HttpURLConnection conn = (HttpURLConnection) fileUrl.openConnection();
        conn.setDoInput(true
); conn.connect(); InputStream is = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) { e.printStackTrace(); } return bitmap; }