Java Code Examples for android.graphics.Bitmap#getRowBytes()

The following examples show how to use android.graphics.Bitmap#getRowBytes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: BlurTestAndroid   File: BitmapUtil.java    License: Apache License 2.0 5 votes vote down vote up
@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 {
        return data.getAllocationByteCount();
    }
}
 
Example 2
Source Project: videocreator   File: BitmapUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 从图片中获取字节数组
 */
public static byte[] getBytes(Bitmap bitmap) {
    byte[] buffer = new byte[bitmap.getRowBytes() * bitmap.getHeight()];
    Buffer byteBuffer = ByteBuffer.wrap(buffer);
    bitmap.copyPixelsToBuffer(byteBuffer);
    return buffer;
}
 
Example 3
public CacheableBitmapDrawable(String url, Resources resources, Bitmap bitmap,
        BitmapLruCache.RecyclePolicy recyclePolicy, int source) {
    super(resources, bitmap);

    mMemorySize = null != bitmap ? (bitmap.getRowBytes() * bitmap.getHeight()) : 0;
    mUrl = url;
    mRecyclePolicy = recyclePolicy;
    mDisplayingCount = 0;
    mHasBeenDisplayed = false;
    mCacheCount = 0;
    mSource = source;
    mReused = false;
}
 
Example 4
Source Project: base-imageloader   File: ImageLoader.java    License: Apache License 2.0 5 votes vote down vote up
private LruCache createDefaultLruCache()
{
    int memCacheSize = mMaxMemCacheSize;
    int maxMemory = (int) Runtime.getRuntime().maxMemory();
    memCacheSize = memCacheSize <= 0 ? maxMemory / 8 : memCacheSize;
    return new LruCache<String, Bitmap>(memCacheSize)
    {
        @Override
        protected int sizeOf(String key, Bitmap value)
        {
            return value.getRowBytes() * value.getHeight();
        }
    };
}
 
Example 5
Source Project: DoraemonKit   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
static int getBitmapBytes(Bitmap bitmap) {
  int result;
  if (SDK_INT >= HONEYCOMB_MR1) {
    result = BitmapHoneycombMR1.getByteCount(bitmap);
  } else {
    result = bitmap.getRowBytes() * bitmap.getHeight();
  }
  if (result < 0) {
    throw new IllegalStateException("Negative size: " + bitmap);
  }
  return result;
}
 
Example 6
Source Project: Dali   File: LegacySDKUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * returns the bytesize of the give bitmap
 */
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();
    }
}
 
Example 7
Source Project: Ticket-Analysis   File: Utils.java    License: MIT License 5 votes vote down vote up
/**
 * Get the size in bytes of a bitmap.
 *
 * @param bitmap
 * @return size in bytes
 */
@TargetApi(12)
public static int getBitmapSize(Bitmap bitmap) {
    if (Utils.hasHoneycombMR1()) {
        return bitmap.getByteCount();
    }
    // Pre HC-MR1
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
Example 8
/**
 * 得到bitmap的大小
 */
public static int getBitmapSize(Bitmap bitmap) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {    //API 19
        return bitmap.getAllocationByteCount();
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {//API 12
        return bitmap.getByteCount();
    }
    // 在低版本中用一行的字节x高度
    return bitmap.getRowBytes() * bitmap.getHeight();                //earlier version
}
 
Example 9
Source Project: candybar   File: LRULimitedMemoryCache.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 10
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}
 
Example 11
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 12
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 13
Source Project: candybar   File: FIFOLimitedMemoryCache.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 14
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 15
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}
 
Example 16
Source Project: twitt4droid   File: Images.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected int sizeOf(String key, Bitmap bitmap) {
    return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
}
 
Example 17
protected int getSize(Bitmap bitmap)
{
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
Example 18
@Override
protected int sizeOf(String key, Bitmap bitmap) {
    return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
}
 
Example 19
Source Project: ghwatch   File: MemoryCache.java    License: Apache License 2.0 4 votes vote down vote up
long getSizeInBytes(Bitmap bitmap) {
  if (bitmap == null)
    return 0;
  return bitmap.getRowBytes() * bitmap.getHeight();
}
 
Example 20
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}