Exemple #1
0
        /// <summary>
        /// Loads the image from the given path
        /// </summary>
        /// <param name="path">Path of image that should be used for this banner</param>
        /// <returns>True if successful, false otherwise</returns>
        protected async Task <Image> LoadImageAsync(String path)
        {
            try
            {
                WebClient client  = new CompressionWebClient();
                byte[]    imgData = await client.DownloadDataTaskAsync(path).ConfigureAwait(false);

                MemoryStream ms  = new MemoryStream(imgData);
                Image        img = Image.FromStream(ms, true, true);
                return(img);
            }
            catch (Exception ex)
            {
                Log.Error("Error while loading image ", ex);
                return(null);
            }
        }
Exemple #2
0
        public async Task <byte[]> LoadImageDataAsync()
        {
            string url = TvdbLinkCreator.CreateBannerLink(BannerPath);

            try
            {
                WebClient client = new CompressionWebClient();
                return(await client.DownloadDataTaskAsync(url).ConfigureAwait(false));
            }
            catch (WebException ex)
            {
                //Server probably returned an error/not found, just log at debug level
                Log.Debug($"TvdbBanner: WebException while loading image from '{url}' - {ex.Message}");
            }
            catch (Exception ex)
            {
                Log.Error($"TvdbBanner: Error while loading image from '{url}'", ex);
            }
            return(null);
        }