我正在尝试使用VB.NET调整使用ASP.net中的FileUpload控件上传的图像
我正在使用文件上传代码:
If FileUpload1.HasFile Then
Dim theFileName As String = Path.Combine(Server.MapPath("~/Uploads"), newfile)
FileUpload1.SaveAs(theFileName)
End If
如何将图像调整为宽度:270像素高度:307像素?
答案 0 :(得分:1)
嗯,我希望这有帮助:
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