vb.net保存图像操作方法

来源:互联网 发布:月度销售数据分析 编辑:程序博客网 时间:2024/05/17 23:43
 '浏览图像文件    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