2020年8月31日 星期一

vb.net 圖片裡加文字 [Add text into Image]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim str As String = "C:\SmallGCOk\中文練習簿生成軟體 (加入拼音軟體)\窗.jpg"
        Dim img As Image = Image.FromFile(str)
        Dim gr As Graphics = Graphics.FromImage(img)
        Dim sf As StringFormat = New StringFormat()
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center
        gr.DrawString("Chuang", New Font("Calibri", 15, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 60, 18, 120)), 54, 37, sf)
        'gr.DrawString("Chuang", New Font("Calibri", Convert.ToSingle(TextBox3.Text), FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 60, 18, 120)), TextBox1.Text, TextBox2.Text, sf)
        gr.Dispose()
        img.Save("C:\SmallGCOk\中文練習簿生成軟體 (加入拼音軟體)\窗New.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
    End Sub

沒有留言:

張貼留言