Android Bitmap Load downloadBitmap(URI uri)

Here you can find the source of downloadBitmap(URI uri)

Description

download Bitmap

Declaration

private static Bitmap downloadBitmap(URI uri) 

Method Source Code

//package com.java2s;
import java.io.BufferedInputStream;

import java.io.InputStream;

import java.net.URI;

import java.net.URLConnection;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.util.Log;

public class Main {
    private static final String TAG = "SOHelper";

    private static Bitmap downloadBitmap(URI uri) {
        try {/*from  ww w.  j a  v  a  2s  .c om*/
            URLConnection connection = uri.toURL().openConnection();
            connection.connect();
            InputStream is = connection.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is, 8 * 1024);
            Bitmap bmp = BitmapFactory.decodeStream(bis);
            bis.close();
            is.close();
            return bmp;
        } catch (Exception ex) {
            Log.w(TAG, "couldn't download image (" + ex.getMessage() + ")");
            return null;
        }
    }
}

Related

  1. getBitmapFromAsset(String strName, Context context)
  2. getBitmapFromInternet(String strName)
  3. getBitmapFromUri(Context ctxt, Uri selectedImageURI)
  4. getBitmapFromUrl(String url)
  5. loadBitmapFromFile(String fileNameWithPath)
  6. returnBitMap(String path)
  7. getBitmapStoragePath(Context context)
  8. getTempBitmap(Context context)
  9. createBitmapFromImageFile(File imagefile)