Blacker.Scraper.Helpers.WebHelper.GetImageFromUrl C# (CSharp) Method

GetImageFromUrl() public static method

public static GetImageFromUrl ( string imageUrl ) : Image
imageUrl string
return Image
        public static Image GetImageFromUrl(string imageUrl)
        {
            if (imageUrl == null)
                throw new ArgumentNullException("imageUrl");

            try
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();

                var request = HttpWebRequest.Create(imageUrl);
                using (var response = request.GetResponse())
                using (var stream = response.GetResponseStream())
                {
                    MemoryStream memoryStream = new MemoryStream();
                    stream.CopyTo(memoryStream);

                    stopWatch.Stop();
                    _log.DebugFormat("Download of image from URL '{0}' took '{1}'", imageUrl, stopWatch.Elapsed);

                    return new Bitmap(memoryStream);
                }
            }
            catch (Exception ex)
            {
                throw new HttpException("Could not load remote website.", ex);
            }
        }