RSS Links

 

Here are all of the RSS links for sections of this site

VB.NET/ASP.NET
 Java
 Unix/Linux
 Windows
 SQL Server

Home arrow VB.NET/ASP.NET arrow How to resize an image in asp.net
How to resize an image in asp.net PDF Print E-mail
Monday, 25 May 2009
To resize an image use the following code

where imgHeight and imgWidth is what you want to image to be


                    Dim oImg As System.Drawing.Image = System.Drawing.Image.FromStream(fileUpload.PostedFile.InputStream)
                    Dim oResized As System.Drawing.Image = New Bitmap(imgWidth, imgHeight)
                    Dim oGraphic As Graphics = Graphics.FromImage(oResized)
                    oGraphic.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
                    oGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
                    oGraphic.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    Dim oRectangle As Rectangle = New Rectangle(0, 0, imgWidth, imgHeight)
                    oGraphic.DrawImage(oImg, oRectangle)
                    oResized.Save(actualPath & fileName & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
                    oImg.Dispose()
 
< Prev   Next >
 
Designed by Graham Robinson Software