public static Bitmap GetImageFromUrl(string url, bool forceNoCache = false) { try { CachingHelpers.CacheStructureBuilder(); if (string.IsNullOrEmpty(url)) { return(Resources.unavailable); } if (!forceNoCache) { if (ThumbCaching.ThumbInCache(url)) { return(ThumbCaching.ThumbFromCache(url)); } } } catch (UnauthorizedAccessException ex) { LoggingHelpers.RecordException(ex.Message, "ThumbIOAccessError"); } catch (Exception ex) { LoggingHelpers.RecordException(ex.Message, "ImageFetchError"); return(Resources.unavailable); } return(ForceImageFromUrl(url)); }
public static Bitmap getImageFromUrl(string url) { Helpers.CacheStructureBuilder(); if (url == "") { return(PlexDL.Properties.Resources.image_not_available_png_8); } else { if (ThumbCaching.ThumbInCache(url)) { return(ThumbCaching.ThumbFromCache(url)); } else { var request = System.Net.WebRequest.Create(url); using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { Bitmap result = (Bitmap)Bitmap.FromStream(stream); ThumbCaching.ThumbToCache(result, url); return(result); } } } }