Creating image thumbnails in asp.net

  • Published on
    26-Jun-2015

  • View
    1.554

  • Download
    2

Embed Size (px)

Transcript

<ul><li> 1. Creating image thumbnails in ASP.NET1: using System;2: using System.Configuration;3: using System.Data;4: using System.Linq;5: using System.Web;6: using System.Web.Security;7: using System.Web.UI;8: using System.Web.UI.HtmlControls;9: using System.Web.UI.WebControls; 10: using System.Web.UI.WebControls.WebParts; 11: using System.Xml.Linq; 12: 13: public partial class _Default : System.Web.UI.Page 14: { 15: protected void Page_Load(object sender, EventArgs e) 16: { 17: 18: } 19: protected void Button1_Click(object sender, EventArgs e) 20: { 21: string target = Server.MapPath("~/Upload"); 22: System.Drawing.Image.GetThumbnailImageAbort thumbnailImageAbortDelegate= new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);23: if (FileUpload1.HasFile) 24: {25: FileUpload1.SaveAs(System.IO.Path.Combine(target,FileUpload1.FileName)); 26: using (System.Drawing.Bitmap originalImage = newSystem.Drawing.Bitmap(FileUpload1.PostedFile.InputStream)) 27: { 28: using (System.Drawing.Image thumbnail =originalImage.GetThumbnailImage(80, 80, thumbnailImageAbortDelegate, IntPtr.Zero))29: {30: thumbnail.Save(System.IO.Path.Combine(target, "thumb_" +FileUpload1.FileName));31: }32: } 33: Image1.ImageUrl = "Upload/" + FileUpload1.FileName; 34: Image2.ImageUrl = "Upload/" + "thumb_" + FileUpload1.FileName; 35: } 36: } 37: public bool ThumbnailCallback() 38: { 39: return false; 40: } 41: }</li></ul> <p> 2. Download Source Code</p>

Recommended

View more >