本文整理汇总了Java中com.facebook.imageutils.BitmapUtil.getSizeInBytes方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapUtil.getSizeInBytes方法的具体用法?Java BitmapUtil.getSizeInBytes怎么用?Java BitmapUtil.getSizeInBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.imageutils.BitmapUtil
的用法示例。
在下文中一共展示了BitmapUtil.getSizeInBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pinBitmap
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
* Pins the bitmap
*/
public CloseableReference<Bitmap> pinBitmap(Bitmap bitmap) {
try {
// Real decoding happens here - if the image was corrupted, this will throw an exception
Bitmaps.pinBitmap(bitmap);
} catch (Exception e) {
bitmap.recycle();
throw Throwables.propagate(e);
}
if (!mUnpooledBitmapsCounter.increase(bitmap)) {
int bitmapSize = BitmapUtil.getSizeInBytes(bitmap);
bitmap.recycle();
String detailMessage = String.format(
Locale.US,
"Attempted to pin a bitmap of size %d bytes."
+ " The current pool count is %d, the current pool size is %d bytes."
+ " The current pool max count is %d, the current pool max size is %d bytes.",
bitmapSize,
mUnpooledBitmapsCounter.getCount(),
mUnpooledBitmapsCounter.getSize(),
mUnpooledBitmapsCounter.getMaxCount(),
mUnpooledBitmapsCounter.getMaxSize());
throw new TooManyBitmapsException(detailMessage);
}
return CloseableReference.of(bitmap, mUnpooledBitmapsCounter.getReleaser());
}
示例2: increase
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
* Includes given bitmap in the bitmap count. The bitmap is included only if doing so
* does not violate configured limit
*
* @param bitmap to include in the count
* @return true if and only if bitmap is successfully included in the count
*/
public synchronized boolean increase(Bitmap bitmap) {
final int bitmapSize = BitmapUtil.getSizeInBytes(bitmap);
if (mCount >= mMaxCount || mSize + bitmapSize > mMaxSize) {
return false;
}
mCount++;
mSize += bitmapSize;
return true;
}
示例3: decrease
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
* Excludes given bitmap from the count.
*
* @param bitmap to be excluded from the count
*/
public synchronized void decrease(Bitmap bitmap) {
final int bitmapSize = BitmapUtil.getSizeInBytes(bitmap);
Preconditions.checkArgument(mCount > 0, "No bitmaps registered.");
Preconditions.checkArgument(
bitmapSize <= mSize,
"Bitmap size bigger than the total registered size: %d, %d",
bitmapSize,
mSize);
mSize -= bitmapSize;
mCount--;
}
示例4: getSizeInBytes
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
@Override
public synchronized int getSizeInBytes() {
int size = 0;
for (int i = 0; i < mBitmapSparseArray.size(); i++) {
size += BitmapUtil.getSizeInBytes(mBitmapSparseArray.valueAt(i).get());
}
return size;
}
示例5: getSizeInBytes
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
@Override
public synchronized int getSizeInBytes() {
return mLastBitmapReference == null
? 0
: BitmapUtil.getSizeInBytes(mLastBitmapReference.get());
}
示例6: getBitmapSizeBytes
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
private static int getBitmapSizeBytes(@Nullable CloseableImage image) {
if (!(image instanceof CloseableBitmap)) {
return 0;
}
return BitmapUtil.getSizeInBytes(((CloseableBitmap) image).getUnderlyingBitmap());
}
示例7: getSizeInBytes
import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
* @return size in bytes of the underlying bitmap
*/
@Override
public int getSizeInBytes() {
return BitmapUtil.getSizeInBytes(mBitmap);
}