16,718
社区成员
发帖
与我相关
我的任务
分享
Public Class Form1
Private p As Point
Private img As Image = New Bitmap("D:\XXX.png")
Private l As New Point(100, 100)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = img
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
p = e.Location
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim v = e.Location - p
Dim g = PictureBox1.CreateGraphics()
Dim a As Rectangle = New Rectangle(l - v, New Size(New Point(PictureBox1.Width, PictureBox1.Height)))
g.DrawImage(img, 0, 0, a, GraphicsUnit.Pixel)
End Sub
End Class