List of usage examples for android.graphics Bitmap getAllocationByteCount
public final int getAllocationByteCount()
From source file:com.sqkj.engine.image.ImageCache.java
private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { //BEGIN_INCLUDE(can_use_for_inbitmap) if (!SdkUtils.hasKitKat()) { // On earlier versions, the dimensions must match exactly and the inSampleSize must be 1 return candidate.getWidth() == targetOptions.outWidth && candidate.getHeight() == targetOptions.outHeight && targetOptions.inSampleSize == 1; }// ww w. j av a 2 s . com // From Android 4.4 (KitKat) onward we can re-use if the byte size of the new bitmap // is smaller than the reusable bitmap candidate allocation byte count. int width = targetOptions.outWidth / targetOptions.inSampleSize; int height = targetOptions.outHeight / targetOptions.inSampleSize; int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); //END_INCLUDE(can_use_for_inbitmap) }
From source file:com.commonsware.android.bitmap.iss.BitmapFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private int byteCount(Bitmap b) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return (b.getAllocationByteCount()); }/*from ww w . ja va 2s . co m*/ return (b.getByteCount()); }
From source file:hochschuledarmstadt.photostream_tools.adapter.LruBitmapCache.java
@Override protected int sizeOf(Integer key, Bitmap value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return value.getAllocationByteCount() / 1024; } else {//from w ww . j ava 2s. c om return value.getByteCount() / 1024; } }
From source file:com.chanlytech.unicorn.cache.ImageCache.java
/** * @param candidate/*from www . j a va 2 s . co m*/ * - Bitmap to check * @param targetOptions * - Options that have the out* value populated * * @return true if <code>candidate</code> can be used for inBitmap re-use with * <code>targetOptions</code> */ @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { //BEGIN_INCLUDE(can_use_for_inbitmap) if (!AndroidVersion.hasKitKat()) { // On earlier versions, the dimensions must match exactly and the inSampleSize must be 1 return candidate.getWidth() == targetOptions.outWidth && candidate.getHeight() == targetOptions.outHeight && targetOptions.inSampleSize == 1; } // From Android 4.4 (KitKat) onward we can re-use if the byte size of the new bitmap // is smaller than the reusable bitmap candidate allocation byte count. int width = targetOptions.outWidth / targetOptions.inSampleSize; int height = targetOptions.outHeight / targetOptions.inSampleSize; int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); //END_INCLUDE(can_use_for_inbitmap) }
From source file:com.higgses.griffin.cache.ImageCache.java
/** * @param candidate//from w w w . j a va 2 s. c om * - Bitmap to check * @param targetOptions * - Options that have the out* value populated * * @return true if <code>candidate</code> can be used for inBitmap re-use with * <code>targetOptions</code> */ @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { //BEGIN_INCLUDE(can_use_for_inbitmap) if (!GriUAndroidVersion.hasKitKat()) { // On earlier versions, the dimensions must match exactly and the inSampleSize must be 1 return candidate.getWidth() == targetOptions.outWidth && candidate.getHeight() == targetOptions.outHeight && targetOptions.inSampleSize == 1; } // From Android 4.4 (KitKat) onward we can re-use if the byte size of the new bitmap // is smaller than the reusable bitmap candidate allocation byte count. int width = targetOptions.outWidth / targetOptions.inSampleSize; int height = targetOptions.outHeight / targetOptions.inSampleSize; int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); //END_INCLUDE(can_use_for_inbitmap) }
From source file:com.crossbow.volley.toolbox.CrossbowImageCache.java
/** * @param size - number of byes to use for the cache; *///from w w w. j ava2s . co m protected CrossbowImageCache(int size) { imageCache = new LruCache<String, Bitmap>(size) { @Override protected int sizeOf(String key, Bitmap value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return value.getAllocationByteCount(); } else { return value.getRowBytes() * value.getHeight(); } } }; }
From source file:io.indy.seni.util.ImageCache.java
/** * @param candidate - Bitmap to check//from w w w . j ava2 s. co m * @param targetOptions - Options that have the out* value populated * @return true if <code>candidate</code> can be used for inBitmap re-use with * <code>targetOptions</code> */ @TargetApi(VERSION_CODES.KITKAT) private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { if (!AppConfig.hasKitKat()) { // On earlier versions, the dimensions must match exactly and the inSampleSize must be 1 return candidate.getWidth() == targetOptions.outWidth && candidate.getHeight() == targetOptions.outHeight && targetOptions.inSampleSize == 1; } // From Android 4.4 (KitKat) onward we can re-use if the byte size of the new bitmap // is smaller than the reusable bitmap candidate allocation byte count. int width = targetOptions.outWidth / targetOptions.inSampleSize; int height = targetOptions.outHeight / targetOptions.inSampleSize; int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); }
From source file:com.meg7.soas.util.BitmapLruCache.java
@SuppressLint("NewApi") @Override//from w w w . jav a2s.c om protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes rather than // number of items. if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) { return bitmap.getAllocationByteCount() / 1024; } else if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount() / 1024; } else { return bitmap.getRowBytes() * bitmap.getHeight() / 1024; } }
From source file:de.s2hmobile.bitmaps.ImageCache.java
/** * @param candidate/*from w ww . j av a 2s.c om*/ * - Bitmap to check * @param targetOptions * - Options that have the out* value populated * @return true if <code>candidate</code> can be used for inBitmap re-use * with <code>targetOptions</code> */ // private static boolean canUseForInBitmap(final Bitmap candidate, // final BitmapFactory.Options targetOptions) { // final int width = targetOptions.outWidth / targetOptions.inSampleSize; // final int height = targetOptions.outHeight / targetOptions.inSampleSize; // // return candidate.getWidth() == width && candidate.getHeight() == height; // } @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { final int outWidth = targetOptions.outWidth; final int outHeight = targetOptions.outHeight; final int inSampleSize = targetOptions.inSampleSize; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // From Android 4.4 (KitKat) onward we can re-use if the byte size // of the new bitmap is smaller than the reusable bitmap candidate // allocation byte count. final int width = outWidth / inSampleSize; final int height = outHeight / inSampleSize; final int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); } // On earlier versions, the dimensions must match exactly and the // inSampleSize must be 1 // TODO in our implementation, the sample size is never one return candidate.getWidth() == outWidth && candidate.getHeight() == outHeight && inSampleSize == 1; }
From source file:com.itsherpa.andg.imageloader.ImageCache.java
/** * @param candidate//from ww w . j a va2 s. com * - Bitmap to check * @param targetOptions * - Options that have the out* value populated * @return true if <code>candidate</code> can be used for inBitmap re-use * with <code>targetOptions</code> */ @TargetApi(19) private static boolean canUseForInBitmap(Bitmap candidate, BitmapFactory.Options targetOptions) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // From Android 4.4 (KitKat) onward we can re-use if the byte size // of // the new bitmap is smaller than the reusable bitmap candidate // allocation byte count. int width = targetOptions.outWidth / targetOptions.inSampleSize; int height = targetOptions.outHeight / targetOptions.inSampleSize; int byteCount = width * height * getBytesPerPixel(candidate.getConfig()); return byteCount <= candidate.getAllocationByteCount(); } // On earlier versions, the dimensions must match exactly and the // inSampleSize must be 1 return candidate.getWidth() == targetOptions.outWidth && candidate.getHeight() == targetOptions.outHeight && targetOptions.inSampleSize == 1; }