28 Ocak 2012, 03:11
|
#1 |
Üyelik Tarihi: 12 Ocak 2012 Rep Puanı : 10 Rep Derecesi :  | Asp.net de Resim Boyutlandırma Kodu [Yanlizca 10 Saniyede Üye Olmak Için TIKLAYINIZ...] [Yanlizca 10 Saniyede Üye Olmak Için TIKLAYINIZ...]ndan bahsedeceğiz. Ayrıca bu benim de kullandıgım boyutlandırma kodudur. Kod: public System.Drawing.Image ResimBoyutlandir(System.Dr
awing.Image imgPhoto, int Yukseklik) {
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int destWidth = Yukseklik;
int destHeight = 200; Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb); bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
Graphics grPhoto = Graphics.FromImage(bmPhoto); grPhoto.
InterpolationMode = InterpolationMode.HighQualityBicubic; grPhoto.FillRectangle(Brushes.White, 0, 0, destWidth, destHeight);
grPhoto.DrawImage(imgPhoto, new Rectangle(0, 0, destWidth, destHeight), new Rectangle(0, 0, sourceWidth, sourceHeight), GraphicsUnit.Pixel);
grPhoto.Dispose(); return bmPhoto; } Kullanışı if (FileUpload1.HasFile == true)
{ string imageName = FileUpload1.FileName; if (imageName != null) { System.Drawing.Image imgPhotoVert = System.Drawing.Image.FromFile(Server.MapPath(Klasor));
System.Drawing.Image imgPhoto = null; Images img =
new Images(); imgPhoto = img.ResimBoyutlandir(imgPhotoVert, yeniW); /
/ScaleByPercent adlı mekanızmaya yolluyoruz aldığımız bilgileri. imgPhoto.Save
(Server.MapPath("~/upload/" + gelenResim), ImageFormat.Jpeg);
// Ekrana basıyoruz.. imgPhoto.Dispose(); } |
| |
| Sponsor Linkler (Lütfen Sitemize Destek Olmak İçin Günde Bir Kez Tıklayınız) |
| |