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


Java BitmapUtil.getSizeInByteForBitmap方法代码示例

本文整理汇总了Java中com.facebook.imageutils.BitmapUtil.getSizeInByteForBitmap方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapUtil.getSizeInByteForBitmap方法的具体用法?Java BitmapUtil.getSizeInByteForBitmap怎么用?Java BitmapUtil.getSizeInByteForBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.imageutils.BitmapUtil的用法示例。


在下文中一共展示了BitmapUtil.getSizeInByteForBitmap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBitmapInternal

import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
/**
 * Creates a bitmap of the specified width and height.
 * @param width the width of the bitmap
 * @param height the height of the bitmap
 * @param bitmapConfig the {@link android.graphics.Bitmap.Config}
 * used to create the decoded Bitmap
 * @return a reference to the bitmap
 * @exception java.lang.OutOfMemoryError if the Bitmap cannot be allocated
 */
@Override
public CloseableReference<Bitmap> createBitmapInternal(
    int width,
    int height,
    Bitmap.Config bitmapConfig) {
  int sizeInBytes = BitmapUtil.getSizeInByteForBitmap(width, height, bitmapConfig);
  Bitmap bitmap = mBitmapPool.get(sizeInBytes);
  Bitmaps.reconfigureBitmap(bitmap, width, height, bitmapConfig);
  return CloseableReference.of(bitmap, mBitmapPool);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ArtBitmapFactory.java

示例2: bitmapSize

import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
public static int bitmapSize(int width, int height, Bitmap.Config config) {
  return BitmapUtil.getSizeInByteForBitmap(width, height, config);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:MockBitmapFactory.java

示例3: decodeStaticImageFromStream

import com.facebook.imageutils.BitmapUtil; //导入方法依赖的package包/类
protected CloseableReference<Bitmap> decodeStaticImageFromStream(
    InputStream inputStream, BitmapFactory.Options options, @Nullable Rect regionToDecode) {
  Preconditions.checkNotNull(inputStream);
  int targetWidth = options.outWidth;
  int targetHeight = options.outHeight;
  if (regionToDecode != null) {
    targetWidth = regionToDecode.width();
    targetHeight = regionToDecode.height();
  }
  int sizeInBytes =
      BitmapUtil.getSizeInByteForBitmap(targetWidth, targetHeight, options.inPreferredConfig);
  final Bitmap bitmapToReuse = mBitmapPool.get(sizeInBytes);
  if (bitmapToReuse == null) {
    throw new NullPointerException("BitmapPool.get returned null");
  }
  options.inBitmap = bitmapToReuse;

  Bitmap decodedBitmap = null;
  ByteBuffer byteBuffer = mDecodeBuffers.acquire();
  if (byteBuffer == null) {
    byteBuffer = ByteBuffer.allocate(DECODE_BUFFER_SIZE);
  }
  try {
    options.inTempStorage = byteBuffer.array();
    if (regionToDecode != null) {
      BitmapRegionDecoder bitmapRegionDecoder = null;
      try {
        bitmapToReuse.reconfigure(targetWidth, targetHeight, options.inPreferredConfig);
        bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, true);
        decodedBitmap = bitmapRegionDecoder.decodeRegion(regionToDecode, options);
      } catch (IOException e) {
        FLog.e(TAG, "Could not decode region %s, decoding full bitmap instead.", regionToDecode);
      } finally {
        if (bitmapRegionDecoder != null) {
          bitmapRegionDecoder.recycle();
        }
      }
    }
    if (decodedBitmap == null) {
      decodedBitmap = BitmapFactory.decodeStream(inputStream, null, options);
    }
  } catch (RuntimeException re) {
    mBitmapPool.release(bitmapToReuse);
    throw re;
  } finally {
    mDecodeBuffers.release(byteBuffer);
  }

  if (bitmapToReuse != decodedBitmap) {
    mBitmapPool.release(bitmapToReuse);
    decodedBitmap.recycle();
    throw new IllegalStateException();
  }

  return CloseableReference.of(decodedBitmap, mBitmapPool);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:57,代码来源:ArtDecoder.java


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