using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace GdiPlus { /// /// ThumbNail : Ãà¼ÒÆÇ À̹ÌÁö ¸¸µé±â /// public class ThumbNail : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { //º¯¼ö ÃʱâÈ­ int boxWidth = 100; int boxHeight = 100; double scale = 0; //ÆÄÀÏ À̸§À» ¼³Á¤ string strFileName = String.Empty; string strSelectedFile = String.Empty; if(Request["FileName"] != null) { strSelectedFile = Request.QueryString["FileName"]; } else { strSelectedFile = "./sample.jpg"; } strFileName = Server.MapPath(strSelectedFile); int tmpW = Convert.ToInt32(Request.QueryString["Width"]); int tmpH = Convert.ToInt32(Request.QueryString["Height"]); if(tmpW > 0 && tmpH > 0) { boxWidth = tmpW; boxHeight = tmpH; } //»õ À̹ÌÁö »ý¼º Bitmap b = new Bitmap(strFileName); //Å©±â ºñÀ²À» °è»êÇÑ´Ù. if(b.Height < b.Width) { scale = ((double)boxHeight)/b.Width; } else { scale = ((double)boxWidth)/b.Height; } //»õ ³Êºñ¿Í ³ôÀ̸¦ ¼³Á¤ÇÑ´Ù. int newWidth = (int)(scale*b.Width); int newHeight = (int)(scale*b.Height); //Ãâ·Â ºñÆ®¸ÊÀ» »ý¼º, Ãâ·ÂÇÑ´Ù. Bitmap bOut = new Bitmap(b, newWidth, newHeight); bOut.Save(Response.OutputStream, b.RawFormat); //¸¶¹«¸® b.Dispose(); bOut.Dispose(); } #region Web Form µðÀÚÀ̳ʿ¡¼­ »ý¼ºÇÑ ÄÚµå override protected void OnInit(EventArgs e) { // // CODEGEN: ÀÌ È£ÃâÀº ASP.NET Web Form µðÀÚÀ̳ʿ¡ ÇÊ¿äÇÕ´Ï´Ù. // InitializeComponent(); base.OnInit(e); } /// /// µðÀÚÀÌ³Ê Áö¿ø¿¡ ÇÊ¿äÇÑ ¸Þ¼­µåÀÔ´Ï´Ù. /// ÀÌ ¸Þ¼­µåÀÇ ³»¿ëÀ» ÄÚµå ÆíÁý±â·Î ¼öÁ¤ÇÏÁö ¸¶½Ê½Ã¿À. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }