如何在文件上载中重新调整图像大小

时间:2021-12-06 21:25:41

I am trying to resize the image that is being uploaded using FileUpload control in ASP.net using VB.NET

我试图使用VB.NET调整使用ASP.net中的FileUpload控件上传的图像

I am using a file upload code:

我正在使用文件上传代码:

If FileUpload1.HasFile Then
    Dim theFileName As String = Path.Combine(Server.MapPath("~/Uploads"), newfile)
    FileUpload1.SaveAs(theFileName)
End If

How do I resize the image to width:270px height:307px?

如何将图像调整为宽度:270px高度:307px?

1 个解决方案

#1


Well, I hope this help :

好吧,我希望这有帮助:

Dim bmp As New Bitmap(FileUpload1.PostedFile.InputStream)
Dim newImage = New Bitmap(newWidth, newHeight)
Using g = Graphics.FromImage(newImage)
    g.DrawImage(bmp, 0, 0, newWidth, newHeight)
End Using

#1


Well, I hope this help :

好吧,我希望这有帮助:

Dim bmp As New Bitmap(FileUpload1.PostedFile.InputStream)
Dim newImage = New Bitmap(newWidth, newHeight)
Using g = Graphics.FromImage(newImage)
    g.DrawImage(bmp, 0, 0, newWidth, newHeight)
End Using