Example usage for android.graphics Bitmap getRowBytes

List of usage examples for android.graphics Bitmap getRowBytes

Introduction

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

Prototype

public final int getRowBytes() 

Source Link

Document

Return the number of bytes between rows in the bitmap's pixels.

Usage

From source file:com.feedback2345sdk.cache.MemoryCache.java

public MemoryCache() {

    // ?//from   www  .  j av a 2 s . c  o  m
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);

    // ?4?
    final int cacheSize = maxMemory / 4;
    mMemeryCache = new LruCache<String, Bitmap>(cacheSize) {

        @Override
        protected int sizeOf(String key, Bitmap bitmap) {
            return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
        }
    };

}

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();
    }//from  w ww .  j  ava2  s .  c om

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

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

From source file:android.bitmap.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 .ja  v a  2 s. co m*/
 * @return size in bytes
 */
@SuppressLint("NewApi")
@TargetApi(VERSION_CODES.GINGERBREAD_MR1)
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: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//w  ww  . j av a2  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 (Global.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }

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

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

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//from w  w  w  .ja va2 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();
}

From source file:com.chatitzemoumin.londoncoffeeapp.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  .  jav a 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 (PlatformUtils.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }

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

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

From source file:com.android.fragmentbase.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 ava  2s. com*/
 * @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 (ImageUtils.hasKitKat()) {
        return bitmap.getAllocationByteCount();
    }

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

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

From source file:com.shizhefei.view.largeimage.ImageManager.java

@TargetApi(Build.VERSION_CODES.KITKAT)
public static int getBitmapSize(Bitmap bitmap) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // API 19
        return bitmap.getAllocationByteCount();
    }//from   ww w  .j a  v  a 2s. c om
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {// API
        return bitmap.getByteCount();
    }
    return bitmap.getRowBytes() * bitmap.getHeight(); // earlier version
}

From source file:com.dp.chapter01.part1.ImageLoader.java

private void initImageCache() {
    // ?//from w w  w .ja v a 2  s.  co m
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    // ?4?
    final int cacheSize = maxMemory / 4;
    mImageCache = new LruCache<String, Bitmap>(cacheSize) {

        @Override
        protected int sizeOf(String key, Bitmap bitmap) {
            return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
        }
    };
}

From source file:com.hataskrau.utils.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).
 *
 * @param value//from  w w  w.  j av  a2  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();
    }

    if (Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1) {
        return bitmap.getByteCount();
    }

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