本文整理汇总了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);
}
示例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);
}
示例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);
}