发布网友
共2个回答
热心网友
或者可以这样,通过像素对比。在大图中查找小图上四个角的像素(四个角的像素可以取大一点),如果是相同的,那就能得出位置了。
如:我先把小图左上角截取10x10的大小,然后在大图上查找跟这10x10相同的区域,如果找到有,那就再确定其它角的区域,因为小图的大小是固定的,所以很容易就算出其它区域在大图在位置,如果四个区域都一样,那基本上就能确定位置了 .
以上是我的想法,不过原理上应该可以做到的追问那需要使用什么软件编程吗?
热心网友
My.Keyboard.Click(Keys.PrintScreen)
Dim scrBitmap As Bitmap = My.Computer.Clipboard().GetImage()
Dim scrWidth As Integer = scrBitmap.Width
Dim scrHeight As Integer = scrBitmap.Height
Dim miniBitmap As Bitmap = System.Drawing.Image.FromFile("c:\Mini.bmp")
Dim LT As System.Drawing.Color = miniBitmap.GetPixel(0, 0)
Dim RT As System.Drawing.Color = miniBitmap.GetPixel(miniBitmap.Width - 1, 0)
Dim LB As System.Drawing.Color = miniBitmap.GetPixel(0, miniBitmap.Height - 1)
Dim RB As System.Drawing.Color = miniBitmap.GetPixel(miniBitmap.Width - 1, miniBitmap.Height - 1)
Dim BitXY As String = ""
For x As Integer = 0 To scrWidth - 1
For y As Integer = 0 To scrHeight - 1
If scrBitmap.GetPixel(x, y).Equals(LT) _
AndAlso scrBitmap.GetPixel(x + miniBitmap.Width - 1, y).Equals(RT) _
AndAlso scrBitmap.GetPixel(x, y + miniBitmap.Height - 1).Equals(LB) _
AndAlso scrBitmap.GetPixel(x + miniBitmap.Width - 1, y + miniBitmap.Height - 1).Equals(RB) Then
BitXY = x & "-" & y
Exit For
End If
End If
Next
If Not BitXY = "" Then Exit For
Next
Me.Text = BitXY