Exemple #1
0
        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);
                        }
                }
            }
        }
Exemple #2
0
        public static Bitmap ForceImageFromUrl(string url)
        {
            try
            {
                var request = WebRequest.Create(url);

                using (var response = request.GetResponse())
                    using (var stream = response.GetResponseStream())
                    {
                        var result = stream != null
                        ? (Bitmap)Image.FromStream(stream)
                        : Resources.unavailable;
                        ThumbCaching.ThumbToCache(result, url);
                        return(result);
                    }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "ImageFetchError");
                return(Resources.unavailable);
            }
        }