List of usage examples for android.graphics Bitmap getRowBytes
public final int getRowBytes()
From source file:org.tigase.messenger.phone.pro.utils.ImageHelper.java
protected static void initialize(Context context) { if (memCache == null) { // Get memory class of this device, exceeding this amount will throw // an OutOfMemory exception. final int memClass = ((android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)) .getMemoryClass();/*from w w w . j a va 2 s . co m*/ // Use 1/8th of the available memory for this memory cache. final int cacheSize = 1024 * 1024 * memClass / 8; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { memCache = new LruCache<String, Bitmap>(cacheSize) { @TargetApi(12) @Override protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in bytes rather than // number of items. Ignoring placeholder bitmap as well. return placeHolders.contains(bitmap) ? 0 : bitmap.getByteCount(); } }; } else { // below SDK 12 there is no getByteCount method memCache = new LruCache<String, Bitmap>(cacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in bytes rather than // number of items. Ignoring placeholder bitmap as well. return placeHolders.contains(bitmap) ? 0 : (bitmap.getRowBytes() * bitmap.getHeight()); } }; } // maps images cache BitmapDiskLruCache diskCache = new BitmapDiskLruCache(); diskCache.initialize(context, "maps", 10 * 1024 * 1024); diskCaches.put("maps", diskCache); // images from files shared with or by us diskCache = new BitmapDiskLruCache(); diskCache.initialize(context, "images-mini", 10 * 1024 * 1024); diskCaches.put("images-mini", diskCache); } }
From source file:com.gokuai.yunkuandroidsdk.imageutils.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. * * @param value/*from ww w .ja va 2 s . c o m*/ * @return size in bytes */ @TargetApi(VERSION_CODES.KITKAT) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); // From KitKat onward use getAllocationByteCount() as allocated bytes can potentially be // larger than bitmap byte count. if (Utils.hasKitKat()) { return bitmap.getAllocationByteCount(); } if (Utils.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:app.eocbox.com.volley.toolbox.BitmapLruCache.java
@Override protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); }
From source file:com.shenma.tvlauncher.network.BitmapLruCache.java
@Override protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); //return value.getRowBytes() * value.getHeight()/1024; }
From source file:inujini_.hatate.volley.BitmapCache.java
public BitmapCache() { int maxSize = 1 * 1024 * 1024; _cache = new LruCache<String, Bitmap>(maxSize) { @Override/*w w w . j a v a 2 s .c o m*/ protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); } }; }
From source file:com.android.fastlibrary.volley.BitmapLruCache.java
@Override protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:br.com.commons.facebooklogin.objects.BitmapLruCache.java
@Override protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight() / 1024; }
From source file:com.test.displaybitmaps.imagemanager.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. Note that from * Android 4.4 (KitKat) onward this returns the allocated memory size of the * bitmap which can be larger than the actual bitmap data byte count (in the * case it was re-used)./*w w w . j a v a2s . c om*/ * * @param value * @return size in bytes */ @TargetApi(VERSION_CODES.KITKAT) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); // From KitKat onward use getAllocationByteCount() as allocated bytes // can potentially be // larger than bitmap byte count. if (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) { return bitmap.getAllocationByteCount(); } if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:org.tigase.mobile.utils.AvatarHelper.java
public static void initilize(Context context_) { if (avatarCache == null) { context = context_;// w w w . jav a 2 s.co m density = context.getResources().getDisplayMetrics().density; defaultAvatarSize = Math.round(density * 50); // Get memory class of this device, exceeding this amount will throw // an // OutOfMemory exception. final int memClass = ((android.app.ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)) .getMemoryClass(); // Use 1/8th of the available memory for this memory cache. final int cacheSize = 1024 * 1024 * memClass / 8; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { avatarCache = new LruCache<BareJID, Bitmap>(cacheSize) { @TargetApi(12) @Override protected int sizeOf(BareJID key, Bitmap bitmap) { // The cache size will be measured in bytes rather than // number of items. Ignoring placeholder bitmap as well. return bitmap == mPlaceHolderBitmap ? 0 : bitmap.getByteCount(); } }; } else { // below SDK 12 there is no getByteCount method avatarCache = new LruCache<BareJID, Bitmap>(cacheSize) { @Override protected int sizeOf(BareJID key, Bitmap bitmap) { // The cache size will be measured in bytes rather than // number of items. Ignoring placeholder bitmap as well. return bitmap == mPlaceHolderBitmap ? 0 : (bitmap.getRowBytes() * bitmap.getHeight()); } }; } mPlaceHolderBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.user_avatar); } }
From source file:com.oneside.base.net.BitmapLruCache.java
@Override protected int sizeOf(String key, Bitmap value) { LogUtils.d("pic size is %s", value.getRowBytes() * value.getHeight()); return value.getRowBytes() * value.getHeight(); }