@Nullable
static Resource<Bitmap> convert(BitmapPool bitmapPool, Drawable drawable, int width, int height) {
// Handle DrawableContainer or StateListDrawables that may contain one or more BitmapDrawables.
drawable = drawable.getCurrent();
Bitmap result = null;
boolean isRecycleable = false;
if (drawable instanceof BitmapDrawable) {
result = ((BitmapDrawable) drawable).getBitmap();
} else if (!(drawable instanceof Animatable)) {
result = drawToBitmap(bitmapPool, drawable, width, height);
// We created and drew to the Bitmap, so it's safe for us to recycle or re-use.
isRecycleable = true;
}
BitmapPool toUse = isRecycleable ? bitmapPool : NO_RECYCLE_BITMAP_POOL;
return BitmapResource.obtain(result, toUse);
}
DrawableToBitmapConverter.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录