1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.PictureBox2.AllowDrop = True
AdaptImage(PictureBox2, PictureBox2.Image, PictureBox2.Size)
AddHandler PictureBox1.MouseDown, AddressOf pictureBox_MouseDown
AddHandler PictureBox2.DragDrop, AddressOf pictureBox_DragDrop
AddHandler PictureBox2.DragEnter, AddressOf pictureBox_DragEnter
End Sub
Private Sub AdaptImage(ByVal pict As PictureBox, ByVal IMG As Image, ByVal new_size As Size)
Dim imageFinale As System.Drawing.Image = Nothing
Dim g As System.Drawing.Graphics = Nothing
imageFinale = New System.Drawing.Bitmap(new_size.Width, new_size.Height)
g = System.Drawing.Graphics.FromImage(imageFinale)
Dim destRect As New System.Drawing.Rectangle(0, 0, new_size.Width, new_size.Height)
Dim srcRect As New System.Drawing.Rectangle(0, 0, IMG.Width, IMG.Height)
g.DrawImage(IMG, destRect, srcRect, System.Drawing.GraphicsUnit.Pixel)
pict.Image = imageFinale
End Sub |
Partager