跪求颜色识别问题

olderboy 2008-03-08 02:04:25
如何识别图象中指定的坐标点是不是某种颜色啊? 急求算法.....
...全文
226 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
olderboy 2008-03-09
  • 打赏
  • 举报
回复
"幸福的子弹"."CommandButton","Sam Liu" 谢谢你们`````

cbm6666 2008-03-08
  • 打赏
  • 举报
回复
'添加 Command1 Picture1

Private Sub Command1_Click()
Dim X1&, Y1&
For X1 = 0 To Picture1.Width
For Y1 = 0 To Picture1.Height
If GetPixel(Picture1.hDC, X1, Y1) = SchColor Then MsgBox CStr(X1) & "," & CStr(Y1): Exit Sub
Next Y1
Next X1
End Sub

cbm6666 2008-03-08
  • 打赏
  • 举报
回复
'更正

Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Dim SchColor&
Private Sub Form_Load()
Picture1.ScaleMode = 3
SchColor = 0 '找黑色
End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Caption = GetPixel(Picture1.hDC, X, Y) & IIf(GetPixel(Picture1.hDC, X, Y) = SchColor, " 找到啦", "")
End Sub

cbm6666 2008-03-08
  • 打赏
  • 举报
回复
'添加 Picture1 装载一张图片

'本代码是鼠标在图片上移动, 找到 黑色 会提示你 找到啦

Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Dim SchColor&
Private Sub Form_Load()
Picture1.ScaleMode = 3
SchColor = 0 '找黑色
End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Caption = GetPixel(Picture1.hDC, X, Y) & IIf(GetPixel(hDCp, X, Y) = SchColor, " 找到啦", "")
End Sub

CommandButton 2008-03-08
  • 打赏
  • 举报
回复
窗体和图片控件的Point方法可以办到啊
qiu5208 2008-03-08
  • 打赏
  • 举报
回复
可以用api函数

1,065

社区成员

发帖
与我相关
我的任务
社区描述
VB 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧