asp.net(vb)生成缩略图函数
2009-12-17 16:59:41 (6493)
Function Thums(ByVal FromImage As String, ByVal ToImage As String, ByVal Del As Boolean, ByVal NewWidth As Integer, ByVal NewHeight As Integer)
Dim Image As System.Drawing.Image
Dim NewImage As System.Drawing.Image
Dim Width As Integer
Dim Height As Integer
Dim Callb As System.Drawing.Image.GetThumbnailImageAbort
Image = System.Drawing.Image.FromFile(Server.MapPath(FromImage))
Width = Image.Width
Height = Image.Height
If FromImage <> ToImage Then
If Width > NewWidth Or Height > NewHeight Then '大于给定得值才处理
If Width > Height Then
NewHeight = Image.Height / Image.Width * NewWidth
Else
NewWidth = Image.Width / Image.Height * NewHeight
End If
NewImage = Image.GetThumbnailImage(NewWidth, NewHeight, Callb, New System.IntPtr)
NewImage.Save(Server.MapPath(ToImage))
Image.Dispose()
Else
System.IO.File.Copy(Server.MapPath(FromImage), Server.MapPath(ToImage))
End If
If Del = True Then
System.IO.File.Delete(Server.MapPath(FromImage))
End If
Else
Return "Error:FromImage can not same to ToImage!"
End If
End Function
了解更多请访问:
http://www.ndfweb.cn/news-489.html