List of usage examples for android.graphics BitmapFactory decodeStream
public static Bitmap decodeStream(InputStream is)
From source file:Main.java
public final static Bitmap Bytes2Bimap(byte[] b) { if (b == null) { return null; }// w ww. jav a 2 s. co m if (b.length != 0) { InputStream is = new ByteArrayInputStream(b); Bitmap bmp = BitmapFactory.decodeStream(is); return bmp; } else { return null; } }
From source file:Main.java
public static Bitmap getBitmapByFile(File file) { FileInputStream fis = null;/*from w ww.j a va 2 s . c o m*/ Bitmap bitmap = null; try { fis = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fis); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } finally { try { fis.close(); } catch (Exception e) { } } return bitmap; }
From source file:Main.java
public static Bitmap getBitmapByString(String imgSrc) { if (imgSrc != null) { byte[] buf = Base64.decode(imgSrc, Base64.NO_WRAP); ByteArrayInputStream bas = new ByteArrayInputStream(buf); Bitmap pic = BitmapFactory.decodeStream(bas); return pic; } else/* w w w . ja v a2 s. c o m*/ return null; }
From source file:Main.java
public static Bitmap getBitmapFromAssert(Context mContext, String imgPath) { Bitmap bitmap = null;//from w w w . jav a2 s . com try { InputStream inputStream = mContext.getAssets().open(imgPath); bitmap = BitmapFactory.decodeStream(inputStream); } catch (IOException e) { return null; } return bitmap; }
From source file:Main.java
public static Bitmap readBitmapFromPath(Context context, Uri path) throws Exception { InputStream stream = context.getContentResolver().openInputStream(path); Bitmap bitmap = BitmapFactory.decodeStream(stream); if (stream != null) { stream.close();// w ww . j a v a2 s . c om } return bitmap; }
From source file:Main.java
public static Bitmap getBitmap(String path) throws FileNotFoundException { FileInputStream fis = new FileInputStream(path); Bitmap bitmap;/*from ww w . ja v a 2 s. co m*/ if (fis == null) { return null; } else { bitmap = BitmapFactory.decodeStream(fis); } return bitmap; }
From source file:Main.java
public static Bitmap converFileToBitMapWithFilePath(Context context, String filePath) { Bitmap result = null;// w w w .j av a 2 s.com try { InputStream is = context.getAssets().open(filePath); result = BitmapFactory.decodeStream(is); } catch (IOException e) { } return result; }
From source file:Main.java
public static Bitmap getBitmap(String path) { try {/*ww w. j av a 2s .c om*/ URL url = new URL(path); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream is = conn.getInputStream(); return BitmapFactory.decodeStream(is); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Bitmap getBitmap(Context context, String fileName) { FileInputStream fis = null;/*from w w w .ja va2s . c om*/ Bitmap bitmap = null; try { fis = context.openFileInput(fileName); bitmap = BitmapFactory.decodeStream(fis); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } finally { try { fis.close(); } catch (Exception e) { } } return bitmap; }
From source file:Main.java
public static Bitmap getBitmapByFile(File file) { FileInputStream fis = null;/*from www . j a v a 2 s. c om*/ Bitmap bitmap = null; try { fis = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fis); } catch (FileNotFoundException e) { } catch (OutOfMemoryError e) { } finally { try { fis.close(); } catch (Exception e) { } } return bitmap; }