日照市东港区创新电子技术中心
ndfweb.cn

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
  NDF俱乐部
  国际域名注册
  建站咨询
合作伙伴:万网 | 新网 | 新网互联 NDF网站建设淘宝店 | 实用工具 | 外貿網站建設 | 联系我们
鲁公网安备 37110202000336号 鲁ICP备2021027697号-1 Sitemap - RSSRSS订阅