首页 > 解决方案 > 如何以最快的方式将图像 URL 转换为位图并保存?

问题描述

bitmap使用时从图像中获取url需要太多时间 -BitmapFactory.decodeStream(url.openConnection().getInputStream())

有没有更好的方法将 url 转换为bitmap并保存image在设备中?因为我的应用程序应该离线工作。我一直在使用多种方法来保存图像,例如 asynctask、picasso 等。所有这些都需要太多时间。这就是为什么我不得不问这个问题。

标签: androidfileurlbitmapimage

解决方案


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());
                            }
                        });

像这样从图像网址加载位图..


推荐阅读