List of usage examples for android.graphics Bitmap getAllocationByteCount
public final int getAllocationByteCount()
From source file:Main.java
/** * Returns the in memory size of the given {@link Bitmap}. *//*from ww w .j a va2s. c o m*/ public static int getSize(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= 19) { return bitmap.getAllocationByteCount(); } else { return bitmap.getHeight() * bitmap.getRowBytes(); } }
From source file:Main.java
public static int getByteCount(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= 19) { return bitmap.getAllocationByteCount(); } else if (Build.VERSION.SDK_INT >= 12) { return bitmap.getByteCount(); } else {//from w w w .j a va 2 s. com return getByteCount(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); } }
From source file:Main.java
@SuppressLint("NewApi") public static int getBitmapSize(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // API 19 return bitmap.getAllocationByteCount(); }//from w w w .j av a 2 s .c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {// API 12 return bitmap.getByteCount(); } return bitmap.getRowBytes() * bitmap.getHeight(); // earlier version }
From source file:Main.java
/** * returns the bytesize of the give bitmap *//*from w w w .jav a 2s . c om*/ public static int byteSizeOf(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return bitmap.getAllocationByteCount(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } else { return bitmap.getRowBytes() * bitmap.getHeight(); } }
From source file:Main.java
public static int getSize(Bitmap image) { int size = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //API 19 size = image.getAllocationByteCount(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {//API 12 size = image.getByteCount();/*from www. j a v a 2 s . co m*/ } else { size = image.getRowBytes() * image.getHeight(); } return size; }
From source file:Main.java
@SuppressLint("NewApi") public static int sizeOfBitmap(Bitmap bitmap) { if (bitmap == null) { return 0; }//w w w. j ava 2s. c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return bitmap.getAllocationByteCount(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return bitmap.getByteCount(); } else { return bitmap.getRowBytes() * bitmap.getHeight(); } }
From source file:com.lark.http.cache.BitmapImageCache.java
@SuppressLint("NewApi") public static int getBitmapSize(Bitmap bitmap) { if (SDKVersionUtil.hasKitKat()) { return bitmap.getAllocationByteCount(); }//ww w . jav a2 s. co m if (SDKVersionUtil.hasHoneycombMR1()) { return bitmap.getByteCount(); } return bitmap.getRowBytes() * bitmap.getHeight(); }
From source file:Main.java
public static int getBitmapSize(Bitmap bitmap) { // From KitKat onward use getAllocationByteCount() as allocated bytes can potentially be // larger than bitmap byte count. if (Build.VERSION.SDK_INT >= KITKAT) { return bitmap.getAllocationByteCount(); }/* www .ja va 2 s.c om*/ // pre kitkat return bitmap.getByteCount(); }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static int sizeOf(Bitmap data) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) { return data.getRowBytes() * data.getHeight(); } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return data.getByteCount(); } else {//from w w w. j a v a 2s .com return data.getAllocationByteCount(); } }
From source file:Main.java
/** * TODO doc/* w w w . j av a 2 s .c om*/ * * @param data * @return */ private static int byteSizeOf(Bitmap data) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) { return data.getRowBytes() * data.getHeight(); } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return data.getByteCount(); } else { return data.getAllocationByteCount(); } }