http://tw.myblog.yahoo.com/chiu-px/article?mid=8&next=7&l=f&fid=6

Function ASP_IMAGE(ByVal durl As String, ByVal surl As String, ByVal w As Integer, ByVal h As Integer)
        'ASP.NET 縮圖功能
        Dim image As System.Drawing.Image
        'Dim anewimage As System.Drawing.Bitmap
        Dim callb As System.Drawing.Image.GetThumbnailImageAbort
        Dim width, height, newwidth, newheight As Integer

        image = System.Drawing.Image.FromFile(durl)
        width = image.Width
        height = image.Height


        If Not (width < w And height < h) Then
            If width > height Then
                h = w * height / width
            Else
                w = h * width / height
            End If
        End If


        Dim img As System.Drawing.Bitmap = New System.Drawing.Bitmap(w, h)
        Dim graphic As Graphics = Graphics.FromImage(img)
        graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
        graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
        graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
        graphic.DrawImage(image, 0, 0, w, h)

        image.Dispose()

        img.Save(surl, System.Drawing.Imaging.ImageFormat.Jpeg)

        img.Dispose()
        graphic.Dispose()


    End Function

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 meltdown 的頭像
    meltdown

    meltdown

    meltdown 發表在 痞客邦 留言(0) 人氣()