List of usage examples for android.graphics Bitmap getByteCount
public final int getByteCount()
From source file:com.fireplace.market.fads.util.ImageCache.java
/** * Get the size in bytes of a bitmap./*from w w w. j ava 2 s . c o m*/ * * @param bitmap * @return size in bytes */ @TargetApi(12) public static int getBitmapSize(Bitmap bitmap) { if (Fireplace.IS_HONEYCOMB_MR1) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.chanlytech.unicorn.cache.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). * * @param value//from w w w.j av a 2s . c o m * * @return size in bytes */ @TargetApi(Build.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 (AndroidVersion.hasKitKat()) { return bitmap.getAllocationByteCount(); } if (AndroidVersion.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.higgses.griffin.cache.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). * * @param value/*w w w.j a v a2 s. co m*/ * * @return size in bytes */ @TargetApi(Build.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 (GriUAndroidVersion.hasKitKat()) { return bitmap.getAllocationByteCount(); } if (GriUAndroidVersion.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.bluetech.gallery5.util.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). * * @param value// ww w. j a v a 2 s. c o m * @return size in bytes */ public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); return bitmap.getByteCount(); }
From source file:Main.java
/** * @return size in bytes of the underlying bitmap *//*from www . jav a2s .co m*/ @SuppressLint("NewApi") public static int getSizeInBytes(@Nullable Bitmap bitmap) { if (bitmap == null) { return 0; } // There's a known issue in KitKat where getAllocationByteCount() can throw an NPE. This was // apparently fixed in MR1: http://bit.ly/1IvdRpd. So we do a version check here, and // catch any potential NPEs just to be safe. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { try { return bitmap.getAllocationByteCount(); } catch (NullPointerException npe) { // Swallow exception and try fallbacks. } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } // Estimate for earlier platforms. Same code as getByteCount() for Honeycomb. return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:Main.java
/** * @return size in bytes of the underlying bitmap *//* www. j a v a2 s.c o m*/ @SuppressLint("NewApi") public static int getSizeInBytes(@Nullable Bitmap bitmap) { if (bitmap == null) { return 0; } // There's a known issue in KitKat where getAllocationByteCount() can throw an NPE. This was // apparently fixed in MR1: http://bit.ly/1IvdRpd. So we do a version check here, and // catch any potential NPEs just to be safe. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { try { return bitmap.getAllocationByteCount(); } catch (NullPointerException npe) { // Swallow exception and try fallbacks. } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } // Estimate for earlier platforms. return bitmap.getWidth() * bitmap.getRowBytes(); }
From source file:us.happ.bitmap.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. * @param value// w w w. j a va 2 s . c o m * @return size in bytes */ @TargetApi(12) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); if (Happ.hasHoneycombMR1) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.wetrain.client.customviews.imagecache.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. * @param value//from w w w . ja v a2s . c om * @return size in bytes */ @TargetApi(12) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); if (Utills.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.afrozaar.jazzfestreporting.util.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. * * @param value/*from w w w .java2s . c om*/ * @return size in bytes */ @TargetApi(12) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); if (Utils.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:com.androidsx.imagesearch.util.ImageCache.java
/** * Get the size in bytes of a bitmap in a BitmapDrawable. * @param value/*ww w .j a v a 2 s . co m*/ * @return size in bytes */ @TargetApi(12) public static int getBitmapSize(BitmapDrawable value) { Bitmap bitmap = value.getBitmap(); if (Platform.hasHoneycombMR1()) { return bitmap.getByteCount(); } // Pre HC-MR1 return bitmap.getRowBytes() * bitmap.getHeight(); }