Example usage for android.graphics BitmapFactory decodeStream

List of usage examples for android.graphics BitmapFactory decodeStream

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeStream.

Prototype

public static Bitmap decodeStream(InputStream is) 

Source Link

Document

Decode an input stream into a bitmap.

Usage

From source file:Main.java

public static Bitmap loadBitmap(String url) {

    Bitmap bitmap = null;//from w  ww .  j a  va2  s  .com

    try {
        InputStream in = new java.net.URL(url).openStream();
        bitmap = BitmapFactory.decodeStream(in);
    } catch (Exception e) {

    }

    return bitmap;
}

From source file:Main.java

public static Bitmap decodeBitmap(String url) {
    try {//from ww  w.  j ava  2 s  .com
        FileInputStream fis = new FileInputStream(url);
        return BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static Bitmap getImageByFile(String uri) {
    try {/*  ww  w  .  j  a v  a  2  s. c  om*/
        FileInputStream fis = new FileInputStream(uri);
        return BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static Bitmap getLoacalBitmap(String url) {
    try {//from www  . jav  a  2s.  c  o m
        FileInputStream fis = new FileInputStream(url);
        return BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static Bitmap loadBitmap(String path, String title) {
    Bitmap bitmap = null;/*from  w  w w  . j a v  a 2  s  .  c  om*/
    try {
        File file = new File(path, title);
        bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
    } catch (Exception e) {

    }
    return bitmap;
}

From source file:Main.java

public static Bitmap getBitmapByURL(String url) {
    Bitmap bm = null;/*w ww. ja  va 2  s .c  om*/

    try {
        bm = BitmapFactory.decodeStream((InputStream) new URL(url).getContent());
    } catch (MalformedURLException e) {
        return null;
    } catch (IOException e) {
        return null;
    }

    return bm;
}

From source file:Main.java

public static Bitmap loadBitmapFromStorage(String path) {
    try {//from ww  w . j  ava  2  s. c om
        FileInputStream is = new FileInputStream(path);
        Bitmap bitmap = BitmapFactory.decodeStream(is);
        return bitmap;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static Bitmap convertByteArrayToBitmap(byte[] byteArray) {
    if (byteArray != null) {
        ByteArrayInputStream imageStream = new ByteArrayInputStream(byteArray);
        return BitmapFactory.decodeStream(imageStream);
    } else {/*from w  w w  .ja  v a  2  s.c o m*/
        return null;
    }
}

From source file:Main.java

public static Bitmap decodeStream(Context paramContext, InputStream paramInputStream) {
    try {/*from ww  w.  ja v a  2  s .  co  m*/
        Bitmap localBitmap = BitmapFactory.decodeStream(paramInputStream);
        return localBitmap;
    } catch (OutOfMemoryError localOutOfMemoryError) {
    }
    return null;
}

From source file:Main.java

public static Bitmap loadImageFromStorage(String path) {

    try {/*from w w w.  j  av a  2  s.co m*/
        File f = new File(path, "profile.jpg");
        Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f));
        return b;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}