upload edilen resimleri istedigim boyuta getirmek için bi yol arıodum
graphics in drawimage metodu guzelce yapıomuş tabi bitmap in getthumbnail metoduda yapıo ama asıl amaç blog um da bide kod olsun :)
kodu görmek için tıklayınız
//resmi yuklemek için
if (FileUpload1.HasFile)
{
ViewState["resimadi"] = FileUpload1.FileName;
byte[] resim = FileUpload1.FileBytes;
Session["resim"] = resim;
System.Drawing.Image bmp = System.Drawing.Image.FromStream(new MemoryStream(resim));
bmp.Height.ToString());
Image1.ImageUrl = "imgresize.aspx";
}
//resmi küçültmek için
MemoryStream ms = new MemoryStream((byte[])Session["resim"]);
Bitmap bmp = new Bitmap(ms);
ms.Dispose();
float percent = (float)Convert.ToInt32(TextBox1.Text) / 100;
int orjw = bmp.Size.Width;
int orjh = bmp.Size.Height;
int n_w = (int)(orjw * percent);
int n_h = (int)(orjh * percent);
Bitmap sonucb = new Bitmap(n_w, n_h);
Graphics gr = Graphics.FromImage(sonucb);
Rectangle drec = new Rectangle(0, 0, sonucb.Width, sonucb.Height);
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
gr.DrawImage(bmp, drec);
gr.Dispose();
MemoryStream ms3 = new MemoryStream();
sonucb.Save(ms3, System.Drawing.Imaging.ImageFormat.Png);
Session["resim"] = ms3.ToArray();
ms3.Dispose();
Image1.ImageUrl = "imgresize.aspx";