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

The following examples show how to use android.graphics.Bitmap#getRowBytes() . 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 check out the related API usage on the sidebar.
Example 1
Source File: ImageCompressUtil.java    From pc-android-controller-android with Apache License 2.0 5 votes vote down vote up
/**
 * 得到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 2
Source File: BitmapUtil.java    From BlurTestAndroid with 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 3
Source File: BitmapUtil.java    From videocreator with 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 4
Source File: CacheableBitmapDrawable.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 5
Source File: ImageLoader.java    From base-imageloader with 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 6
Source File: Utils.java    From Ticket-Analysis with 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 7
Source File: Utils.java    From DoraemonKit with 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 8
Source File: LegacySDKUtil.java    From Dali with 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 9
Source File: LargestLimitedMemoryCache.java    From WliveTV with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}
 
Example 10
Source File: LRULimitedMemoryCache.java    From candybar with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 11
Source File: MemoryCache.java    From ghwatch with 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 12
Source File: BitmapManager.java    From YalpStore with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int sizeOf(String key, Bitmap bitmap) {
    return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
}
 
Example 13
Source File: LargestLimitedMemoryCache.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
protected int getSize(Bitmap bitmap)
{
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
Example 14
Source File: Images.java    From twitt4droid with 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 15
Source File: LargestLimitedMemoryCache.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}
 
Example 16
Source File: UsingFreqLimitedMemoryCache.java    From letv with Apache License 2.0 4 votes vote down vote up
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 17
Source File: FIFOLimitedMemoryCache.java    From candybar with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 18
Source File: UsingFreqLimitedMemoryCache.java    From candybar with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 19
Source File: UsingFreqLimitedMemoryCache.java    From Roid-Library with Apache License 2.0 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
Example 20
Source File: LargestLimitedMemoryCache.java    From mobile-manager-tool with MIT License 4 votes vote down vote up
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}