当前位置: 首页>>代码示例>>Java>>正文


Java BitmapUtil.getSizeInBytes方法代码示例

本文整理汇总了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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:DalvikPurgeableDecoder.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:BitmapCounter.java

示例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--;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:BitmapCounter.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:NaiveCacheAllFramesCachingBackend.java

示例5: getSizeInBytes

import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
@Override
public synchronized int getSizeInBytes() {
  return mLastBitmapReference == null
      ? 0
      : BitmapUtil.getSizeInBytes(mLastBitmapReference.get());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:KeepLastFrameCache.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:FrescoFrameCache.java

示例7: getSizeInBytes

import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
 * @return size in bytes of the underlying bitmap
 */
@Override
public int getSizeInBytes() {
  return BitmapUtil.getSizeInBytes(mBitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CloseableStaticBitmap.java


注:本文中的com.facebook.imageutils.BitmapUtil.getSizeInBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。