2016-06-17 155 views
0

我使用picasso插件来加载图像。保存图像在SD卡后毕加索加载图像

Picasso.with(context).load(BackendConfig.media_url+folder+holder.media_name).resize(150, 150).into(holder.imageView); 

它工作正常。但是,我想通过从URL加载一次将该图像保存在SD卡中。

我该怎么做?

回答

1

毕加索使用LRU磁盘缓存,无需担心从URL加载一次。如果您需要加载并保存实际图像作为文件,请将其加载为位图资源,并使用Bitmap.compressFileOutputStream保存到文件(PNG/JPEG/WEBP)中。

1

你可以使用(对于我自己刨光本)这个轻量级的Android库VINCI它做你想做

  • 缓存的每一件事 - (在保存文件internalStorage)使用LruCache
  • 管理files/bitmaps

阅读此WIKI part更多访问我的github repo

Storage store = Vinci.base(context).process().load(uri).file(); 

Log.e("Created", Boolean.toString(store.isCreated())); 
Log.e("FileObject", store.FileObject().toString()); 
Log.e("FullPath", store.getfullPath().getPath()); 
Log.e("LocalPath", store.LocalPath()); 
Log.e("Get Bitmap File", String.valueOf(store.getBitmap()));