Shaofh

Shaofh

自動生成帶文字的圖片

'str欲添加的文字 , width 圖片寬度,height圖片高度,filename 圖片名
Private Function CreatePic(ByVal Str As String, ByVal width As Integer, ByVal heightAs Integer, ByVal filename As String)
        Dim bitmap As Bitmap = New Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppRgb)
        Dim g As Graphics = Graphics.FromImage(bitmap)
        g.Clear(Color.White)
        Dim f As Font = New Font("System", 9)
        Dim s As SolidBrush = New SolidBrush(Color.Black)
        g.DrawString(Str, f, s, 0, 0)
        Try
            bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Gif)
        Catch ex As Exception
        End Try
        g.Dispose()
        bitmap.Dispose()
End Function

posted on 2006-07-07 14:53  sh37  阅读(1746)  评论(7编辑  收藏  举报

导航