List of usage examples for android.graphics Bitmap isRecycled
public final boolean isRecycled()
From source file:Main.java
public static Bitmap getRotateBitmap(Bitmap bitmap, int rotation) { if (null == bitmap || bitmap.isRecycled()) { return null; }// w w w .j a v a2s .c o m Matrix matrix = new Matrix(); matrix.postRotate(rotation); Bitmap cropBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); return cropBitmap; }
From source file:Main.java
public static void recycleBitmapArr(Bitmap[] bmps) { for (int i = 0; i < bmps.length; i++) { Bitmap mBitmap = bmps[i]; if (mBitmap != null && !mBitmap.isRecycled()) { mBitmap.recycle();/* w w w. ja v a 2s.c o m*/ mBitmap = null; System.gc(); System.runFinalization(); System.gc(); } } }
From source file:Main.java
/** * Safely free all {@link Bitmap} in a bitmap {@link List}. * //from w ww . jav a 2 s .c o m * @param bmpList * Bitmap list. */ public final static void freeBitmapList(List<Bitmap> bmpList) { if (null != bmpList) { for (Bitmap bmp : bmpList) { if (null != bmp && !bmp.isRecycled()) { bmp.recycle(); } } bmpList.clear(); } }
From source file:Main.java
public static byte[] bitmap2Bytes(Bitmap bm) { if (bm == null || bm.isRecycled()) { return null; }/*from ww w . ja v a 2 s . co m*/ byte[] bytes; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); bytes = baos.toByteArray(); try { baos.flush(); baos.close(); } catch (IOException e) { e.printStackTrace(); } return bytes; }
From source file:Main.java
public static void recycle(Bitmap bitmap) { if (bitmap == null) return;// w w w . j a v a2 s . co m if (bitmap.isRecycled()) return; bitmap.recycle(); bitmap = null; }
From source file:Main.java
public static void releaseBitmapArray(Bitmap[] bitmaps) { if (bitmaps != null) { try {/*from w w w . j a va2 s .c o m*/ for (Bitmap bitmap : bitmaps) { if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); } } } catch (Exception e) { } } }
From source file:Main.java
public static void release(Bitmap... bitmaps) { if (bitmaps != null) { try {//from www . j av a2s. c om for (Bitmap bitmap : bitmaps) { if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); } } } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
public static Bitmap rotation90(Bitmap bitmap) { if (bitmap == null) return null; if (bitmap.isRecycled()) return null; Bitmap bmp = null;//from w ww. j a va2 s. c o m Matrix matrix = new Matrix(); matrix.postRotate(90); bmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); bitmap.recycle(); return bmp; }
From source file:Main.java
public static void recycleImageViewBitmap(ImageView imageView) { if (imageView == null) return;/*from w ww. j a v a 2 s.co m*/ Drawable drawable = imageView.getDrawable(); if (drawable != null && drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); if (bitmap != null && !bitmap.isRecycled()) { bitmap.recycle(); } } }
From source file:Main.java
public static void releaseBitmap(Bitmap bitmap) { if (bitmap != null) { try {// ww w . ja v a 2 s. c o m if (!bitmap.isRecycled()) { bitmap.recycle(); } } catch (Exception e) { } bitmap = null; } }