Ejemplo n.º 1
0
        /// <summary>
        /// 从联网下载图片
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static async Task <ImageSource> FetchNetworkImage(string url)
        {
            var stream = await Task.Run(() => {
                return(FileCacheHelper.Hit(url));
            });

            return(LoadImageStream(stream));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从网络上面下载图片,转换成 BitMapImage
        /// </summary>
        /// <param name="url">图片的 url 地址</param>
        /// <param name="bufferSize">读取图片开辟的缓存大小,默认 512K</param>
        /// <returns></returns>
        public static async Task <ImageSource> FetchImage(string url)
        {
            if (CloudStorageHelper.IsCloudImage(url) && !FileCacheHelper.IsCached(url))
            {
                var storage = CloudStorageHelper.GetCloudStorage();
                await storage.GetImage(url, FileCacheHelper.AppCacheDirectory, FileCacheHelper.BuildFileName(url));
            }
            var stream = FileCacheHelper.Hit(url);

            return(LoadImageStream(stream));
        }