我需要使用Imageview下载保存在缓存中的图像,以某种方式让我以简单的方式进行操作?
我可以下载更多未保存在缓存中的下载文件
private Bitmap GetImageBitmapFromUrl(string url)
{
Bitmap imageBitmap = null;
using (var webClient = new WebClient())
{
try
{
var imageBytes = webClient.DownloadData(url);
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
}
}
catch
{
}
}
return imageBitmap;
}
//-----------
**Show image**
var imageBitmap = GetImageBitmapFromUrl("URL");
imageView.SetImageBitmap(imageBitmap);
答案 0 :(得分:0)
答案 1 :(得分:0)
https://github.com/luberda-molinet/FFImageLoading
示例: -
ImageService.Instance.LoadUrl(urlToImage)
.Retry(3, 200)
.DownSample(300, 300)
.Transform(new CircleTransformation())
.Transform(new GrayscaleTransformation())
.LoadingPlaceholder(Config.LoadingPlaceholderPath, ImageSource.ApplicationBundle)
.ErrorPlaceholder(Config.ErrorPlaceholderPath, ImageSource.ApplicationBundle)
.Into(_imgDisplay);