locked
Comment dessiner une image sur le composant PictureBox et l'objet Image RRS feed

  • Discussion générale

  •  

    Il faut trouver le correct objet Graphics correct.  

    Conditions prealables : Ajoutez les composants PictureBox1, Button1 et Button2 sur le formulaire Form1

     

    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            PictureBox1.Image = Image.FromFile("D:\VBproject\2.jpg")
        End Sub
     
             'dessiner une image sur le composant PictureBox
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim newImage As Image = Image.FromFile("D:\VBproject\1.jpg")
            Dim g As Graphics = Me.PictureBox1.CreateGraphics
            g.DrawImage(newImage, New Rectangle(10, 10, 200, 200))
        End Sub
        
             'dessiner une image sur PictureBox.Image
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim newImage As Image = Image.FromFile("D:\VBproject\1.jpg")
            Dim g As Graphics = Graphics.FromImage(PictureBox1.Image)
            g.DrawImage(newImage, New Rectangle(10, 10, 200, 200))
            PictureBox1.Refresh()
        End Sub
    End Class

     

     

    Pour plusieurs questions sur Visual Basic .NET, visitez Foire aux Questions – Visual Basic .NET FAQ et didacticiels

     


    Alex Petrescu - MSFT
    lundi 8 février 2010 12:57