List of usage examples for android.graphics Bitmap recycle
public void recycle()
From source file:Main.java
public static Bitmap resizeBmp(Bitmap bitmap, int requiredSizeW, int requireSizeH) { Bitmap outBitamp = Bitmap.createBitmap(bitmap, 0, 0, requiredSizeW, requireSizeH); bitmap.recycle(); return outBitamp; }
From source file:Main.java
/** * recycle a bitmap/*from w w w . ja v a 2s. c om*/ * @param aBitmap bitmap */ public static void recycleBitmap(Bitmap aBitmap) { if (aBitmap != null) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { aBitmap.recycle(); } } }
From source file:Main.java
/** * byte[] -> Drawable/*from w w w . j ava 2 s . c o m*/ * * @param bytes * @return */ public static BitmapDrawable byteToDrawable(byte[] bytes) { Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, null); BitmapDrawable bd = new BitmapDrawable(bitmap); bitmap.recycle(); bitmap = null; return bd; }
From source file:Main.java
public static void clearImageView(ImageView imageView) { if (!(imageView.getDrawable() instanceof BitmapDrawable)) { return;// w w w . j a v a2s. c o m } Bitmap drawable = ((BitmapDrawable) imageView.getDrawable()).getBitmap(); if (drawable != null && !drawable.isRecycled()) { drawable.recycle(); } imageView.setImageDrawable(null); }
From source file:Main.java
public static Bitmap createScaleBitmap(Bitmap src, int dstWidth, int dstHeight) { Bitmap dst = Bitmap.createScaledBitmap(src, dstWidth, dstHeight, false); if (src != dst) { src.recycle(); }/*w w w .j a va 2s. c om*/ return dst; }
From source file:Main.java
public static final Bitmap cropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight) { Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, cropX, cropY, cropWidth, cropHeight); bitmap.recycle(); return resizedBitmap; }
From source file:Main.java
public static final void recycle(Bitmap bitmap) { System.out.println("==recycle=="); if (bitmap != null && !bitmap.isRecycled()) { System.out.println("--true"); bitmap.recycle(); bitmap = null;// w ww. j a v a 2 s.com System.gc(); } }
From source file:Main.java
private final static void recycle(Bitmap... bitmaps) { if (bitmaps == null || bitmaps.length == 0) { return;/*ww w . j a va2 s. co m*/ } for (Bitmap bitmap : bitmaps) { if (bitmap == null) { continue; } if (!bitmap.isRecycled()) { bitmap.recycle(); continue; } bitmap = null; } System.gc(); }
From source file:Main.java
public static Bitmap ensureGLCompatibleBitmap(Bitmap bitmap) { if (bitmap == null || bitmap.getConfig() != null) return bitmap; Bitmap newBitmap = bitmap.copy(Config.ARGB_8888, false); bitmap.recycle(); return newBitmap; }
From source file:Main.java
/** * Recycle the bitmp if it is not null or recycled. * // w w w. j a va 2s . co m * @param bmp * the bitmap will be recycled for retrieving its memory */ public static void recycleBitmap(Bitmap bmp) { if (bmp == null || bmp.isRecycled()) return; // if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { bmp.recycle(); // } }