> NPO 小記事本: 產生縮圖範例(VB.NET)

2014/8/18

產生縮圖範例(VB.NET)

 
 Sub Thumb_Image(ByVal durl As String, ByVal surl As String, ByVal ThumbWidth As Integer, ByVal ThumbHeight As Integer)
        '產生縮圖範例

        Dim img As New Bitmap(ThumbWidth, ThumbHeight)
        Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(surl)
        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, ThumbWidth, ThumbHeight)

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

        image.Dispose()
        img.Dispose()
        graphic.Dispose()

    End Sub

沒有留言: