VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net保存图像操作方法

 '浏览图像文件
Dim MyImage As Image

Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
    Me.openFileDialog1.Filter = "图像文件(JPeg,Gif,Bmp,etc.)|*.jpg;*.jpeg;*.gif; *.bmp; *.tif; *.tiff; *.png| JPeg 文件 (*.jpg;*.jpeg)|*.jpg;*.jpeg |GIF 文件 (*.gif)|*.gif |BMP 文件 (*.bmp)|*.bmp|Tiff 文件 (*.tif;*.tiff)|*.tif;*.tiff|Png 文件 (*.png)| *.png |所有文件(*.*)|*.*"
    If (Me.openFileDialog1.ShowDialog() = DialogResult.OK) Then
        Me.textBox1.Text = Me.openFileDialog1.FileName
        Me.pictureBox1.Image = Image.FromFile(Me.textBox1.Text)
    End If
End Sub
'添加透明文字
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
    MyImage = Image.FromFile(Me.textBox1.Text)
    Dim g = Graphics.FromImage(MyImage)
    Dim MyText = Me.textBox2.Text
    Dim MyFont = New Font("宋体", 150)
    Dim MyBrush As New SolidBrush(Color.FromArgb(128, 0, 255, 0))
    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected
    g.DrawString(MyText, MyFont, MyBrush, 10, 10)
    Me.pictureBox1.Image = MyImage

End Sub
'保存图像
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    MyImage.Save("c:\kk.jpg")
End Sub


相关教程