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:com.jasper.image.imagemanager.imagehelper.imageEngine.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).//from   w ww.  j av a  2 s.c o  m
 *
 * @param value
 * @return size in bytes
 */
@TargetApi(19)
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 (VersionUtils.hasKitKat()) {
        // return bitmap.getAllocationByteCount();
        return bitmap.getByteCount();
    }

    if (VersionUtils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:ar.com.lapotoca.resiliencia.gallery.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// w ww  .  ja va2  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 (Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
        return bitmap.getAllocationByteCount();
    }

    return bitmap.getByteCount();
}

From source file:com.gelakinetic.mtgfam.helpers.lruCache.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  ww. j  av a 2 s  . c  o m
 * @return size in bytes
 */
@TargetApi(VERSION_CODES.KITKAT)
private 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:com.yineng.ynmessager.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).//from  w  ww.ja v  a  2  s  . c o  m
 *
 * @param value
 * @return size in bytes
 */
@TargetApi(19)
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.getByteCount();
    }

    if (Utils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.rp.justcast.photos.ImageCache.java

@TargetApi(VERSION_CODES.KITKAT)
public static int getBitmapSize(Bitmap bitmap) {
    // From KitKat onward use getAllocationByteCount() as allocated bytes can potentially be
    // larger than bitmap byte count.
    if (JustCastUtils.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }//ww  w  .  j av a 2s.c o  m

    if (JustCastUtils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:dev.dworks.apps.anexplorer.misc.ThumbnailCache.java

@Override
protected int sizeOf(Uri key, Bitmap value) {
    return value.getByteCount();
}

From source file:prince.app.sphotos.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/*from   w  w w  .j  a  v a2s  . co 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 (Global.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }

    if (Global.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:com.onedollar.image.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).//from  w w  w  .j  a  v  a  2 s. c  o  m
 * 
 * @param value
 * @return size in bytes
 */
@TargetApi(VERSION_CODES.JELLY_BEAN)
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.hasJellyBean()) {
        return bitmap.getByteCount();
    }

    if (Utils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }

    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}

From source file:org.spinsuite.util.ImageCacheLru.java

@Override
protected int sizeOf(String key, Bitmap value) {
    return value.getByteCount();
}

From source file:angel.zhuoxiu.picker.utils.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 ava  2 s . co  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();
}