Example usage for android.graphics Bitmap getByteCount

List of usage examples for android.graphics Bitmap getByteCount

Introduction

In this page you can find the example usage for android.graphics Bitmap getByteCount.

Prototype

public final int getByteCount() 

Source Link

Document

Returns the minimum number of bytes that can be used to store this bitmap's pixels.

Usage

From source file:br.com.mybaby.contatos.ImageCache.java

/**
 * Get the size in bytes of a bitmap./*from   www.j a  v a  2 s  .com*/
 *
 * @param bitmap The bitmap to calculate the size of.
 * @return size of bitmap in bytes.
 */
@TargetApi(12)
public static int getBitmapSize(Bitmap bitmap) {
    if (Util.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    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();
    }/*w  w w.j  a v a 2 s.c  o m*/

    if (SDKVersionUtil.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.example.pallavi.catchupcontacts.ImageCache.java

/**
 * Get the size in bytes of a bitmap./*from   w  ww  .  j  a v  a2s  . co  m*/
 *
 * @param bitmap The bitmap to calculate the size of.
 * @return size of bitmap in bytes.
 */
@TargetApi(12)
public static int getBitmapSize(Bitmap bitmap) {
    //        if (Utils.hasHoneycombMR1()) {
    return bitmap.getByteCount();
    //        }
    // Pre HC-MR1
    //        return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:Main.java

@SuppressLint("NewApi")
public static int sizeOfBitmap(Bitmap bitmap) {
    if (bitmap == null) {
        return 0;
    }// w w  w.  ja v a 2s.co 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: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();
    }/*from  w  w w.  j  a  v  a 2s  . c om*/
    // pre kitkat
    return bitmap.getByteCount();
}

From source file:com.mallapp.utils.ImageCache.java

/**
 * Get the size in bytes of a bitmap./*from w  w w  .  j  av  a 2  s.c  om*/
 *
 * @param bitmap The bitmap to calculate the size of.
 * @return size of bitmap in bytes.
 */
@TargetApi(12)
public static int getBitmapSize(Bitmap bitmap) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.example.demo.util.ImageCache.java

@SuppressLint("NewApi")
public static int getBitmapSize(Bitmap bitmap) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        return bitmap.getByteCount();
    }/*from  w  w w.  j  a  va 2  s.co  m*/
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.vinay.volley.lazyload.BitmapCache.java

/**
 * Get the size in bytes of a bitmap./*w w w . j  av  a2s  .  c  o m*/
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public static int getBitmapSize(Bitmap bitmap) {
    if (hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.conferenceengineer.android.iosched.util.BitmapCache.java

/**
 * Get the size in bytes of a bitmap.//from  w w w. j a va2 s  .c o  m
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public static int getBitmapSize(Bitmap bitmap) {
    if (UIUtils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.android.volley.cache.BitmapCache.java

/**
 * Get the size in bytes of a bitmap./*from  ww w .j av  a2  s. c o  m*/
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public static int getBitmapSize(Bitmap bitmap) {
    if (Utils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}