在vb.net中,当我点击图片框中的图片时,我正在修改以捕获鼠标位置并使用图片框1中图像的放大部分填充第二个图片框。
代码似乎正在工作......有点......它抓取了图片框1中图像的一部分......但不是我点击的部分。
Private Function magnify(ByVal position As Point)
vert2.Clear()
horz2.Clear()
Dim img As New Bitmap(preciseBox.Width, preciseBox.Height)
Dim gr As Graphics = Graphics.FromImage(img)
Dim src As New Rectangle(position.X - 50, position.Y - 50, 100, 100)
Dim dest As New Rectangle(0, 0, img.Width, img.Height)
Try
gr.DrawImage(xrayBox.Image, dest, src, GraphicsUnit.Pixel)
img = New Bitmap(img, img.Width, img.Height)
preciseBox.Image = img
'Draws the crosshair on the magnify box
vert2.Add(New Point(img.Width / 2, 0))
vert2.Add(New Point(img.Width / 2, img.Height))
horz2.Add(New Point(0, img.Height / 2))
horz2.Add(New Point(img.Width, img.Height / 2))
draw2 = True
preciseBox.Invalidate()
Catch ex As Exception
End Try
Return 0
End Function
Picturebox1尺寸(运行时):宽度646px高度687px Picturebox1.Image Size(运行时):宽度646px高度484px Picturebox2尺寸(运行时):宽度370px高度230px