11-30-2012، 11:42 PM
کد:
Imports System.Drawing
Imports System.Drawing.Drawing2D
Dim gu As New Guid
gu = Guid.NewGuid
Dim ext As String = Path.GetExtension(FileUpload1.FileName)
ImageName = gu.ToString & ext
FileUpload1.SaveAs(Server.MapPath("~/DynamicImages/News/" & ImageName))
Using fl = File.OpenRead(Server.MapPath("~/DynamicImages/News/" & ImageName))
Using thumbFile = File.Create(Server.MapPath("~/DynamicImages/News/thumbnails/" & ImageName))
ResizeImage(0.1, fl, thumbFile)
End Using
End Using
Private Sub ResizeImage(ByVal scaleFactor As Double, ByVal fromStream As Stream, ByVal toStream As Stream)
Using image__1 = Image.FromStream(fromStream)
'Dim newWidth = CInt(image__1.Width * scaleFactor)
' Dim newHeight = CInt(image__1.Height * scaleFactor)
Dim newWidth = 150
Dim newHeight = 150
Using thumbnailBitmap = New Bitmap(newWidth, newHeight)
Using thumbnailGraph = Graphics.FromImage(thumbnailBitmap)
thumbnailGraph.CompositingQuality = CompositingQuality.HighQuality
thumbnailGraph.SmoothingMode = SmoothingMode.HighQuality
thumbnailGraph.InterpolationMode = InterpolationMode.HighQualityBicubic
Dim imageRectangle = New Rectangle(0, 0, newWidth, newHeight)
thumbnailGraph.DrawImage(image__1, imageRectangle)
thumbnailBitmap.Save(toStream, image__1.RawFormat)
End Using
End Using
End Using
End Sub
اینم ببین
http://www.nerdymusings.com/LPMArticle.asp?ID=32
بهتر از این لینک بالا فکر نکنم بتونم بهت بگم
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg