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,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
原文链接:https://www.f2er.com/vb/260259.html

猜你在找的VB相关文章