public Stream GetThumbnail(string uri) { if (string.IsNullOrEmpty(uri)) { return(null); } else { if ((uri.IndexOf("file:", System.StringComparison.Ordinal) < 0) && (uri.IndexOf("http", System.StringComparison.Ordinal) < 0)) { uri = "http://" + uri; } Thumbnail.Uri = uri; try { Bitmap bitmap = WebsiteThumbnail.GetThumbnail(Thumbnail.Uri, Thumbnail.Width, Thumbnail.Hight, Thumbnail.ThumbWidth, Thumbnail.ThumbHight); return(CheckForBlankPage(bitmap)); } catch (Exception) { throw; } return(null); } }
protected void btnCapturar_Click(object sender, EventArgs e) { Bitmap bmp = WebsiteThumbnail.GetThumbnail(txtUrl.Text, 900, 600, 300, 200); bmp.Save(Server.MapPath("~/images/" + txtUrl.Text + ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg); CargarImagenes(); }
/// <summary> /// Generates a website thumbnail for the given URL /// </summary> /// <param name="url">Address of website from which to generate the /// thumbnail</param> /// <param name="width">Browser width</param> /// <param name="height">Browser height</param> /// <param name="thumbWidth">Width of generated thumbnail</param> /// <param name="thumbHeight">Height of generated thumbnail</param> /// <returns></returns> public static Bitmap GetThumbnail(string url, int width, int height, int thumbWidth, int thumbHeight) { WebsiteThumbnail thumbnail = new WebsiteThumbnail(url, width, height, thumbWidth, thumbHeight); return(thumbnail.GetThumbnail()); }