vb6判断一个图像是否包含另一个图像出现错误

[复制链接]
查看11 | 回复1 | 2011-3-5 19:43:41 | 显示全部楼层 |阅读模式
Dim x1 As Long
Dim y1 As Long
Dim x2 As Long
Dim y2 As Long
Dim panduan As Boolean
Private Sub Command1_Click()
panduan = False
Text1.Text = Picture1.Width / 15 & "*" & Picture1.Height / 15 & "=" & Picture1.Width * Picture1.Height / 225
Text2.Text = Picture2.Width / 15 & "*" & Picture2.Height / 15 & "=" & Picture2.Width * Picture2.Height / 225
For x2 = 1 To Picture2.Width / 15

For y2 = 1 To Picture2.Height / 15

If Picture2.Point(x2 * 15, y2 * 15) = Picture1.Point(15, 15) Then

For x1 = 1 To Picture1.Width / 15

For y1 = 1 To Picture1.Height / 15

If Picture2.Point((x2 + x1 - 1) * 15, (y2 + y1 - 1) * 15) = Picture1.Point(x1, y1) Then

panduan = True

If x1 = Picture1.Width / 15 And y1 = Picture1.Height / 15 Then

MsgBox "成功"

MsgBox "坐标为:" & x2 & "-" & y2 & "以图片2为坐标"

End If

Else

panduan = False

End If

Next

Next

End If

If panduan Then

x2 = Picture2.Width / 15 + 1

y2 = Picture2.Height / 15 + 1

End If

Next
Next
End Sub

回复

使用道具 举报

千问 | 2011-3-5 19:43:41 | 显示全部楼层
应该要判断图像边缘的像素的rgb 值吧?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行