android - 如何以最快的方式将图像 URL 转换为位图并保存?
问题描述
bitmap
使用时从图像中获取url
需要太多时间 -BitmapFactory.decodeStream(url.openConnection().getInputStream())
有没有更好的方法将 url 转换为bitmap
并保存image
在设备中?因为我的应用程序应该离线工作。我一直在使用多种方法来保存图像,例如 asynctask、picasso 等。所有这些都需要太多时间。这就是为什么我不得不问这个问题。
解决方案
Glide.with(this)
.load(strUrl)
.into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
saveMyBitmap(((BitmapDrawable) resource).getBitmap());
}
});
像这样从图像网址加载位图..
推荐阅读
- python - 有没有办法操纵洗牌功能?
- android - Android 6.0 x com.qualcomm.qti.Performance.native_deinit 崩溃
- javascript - 此代码中函数末尾的 0 表示什么?
- ios - 平面渲染视频使用 shaderModifiers ,但颜色太浅
- java - Java前一天转换为unix,昨天格式
- java - 是否有任何仅用于压缩 html 的 maven 插件?
- python - 从传统循环到列表理解
- reactjs - 根据索引检查并选择 1 by 1 后如何 onChange 复选框
- javascript - localStorage 在其他主机中不起作用 - javascript
- c# - 如何在 Web 控件中包含 html 元素,例如 C# 中的 TableCell