本帖最后由 tryhi 于 2011-5-25 15:07 编辑
在补充个问题如果我用RGB色比较(不是用0x123456)这个函数需要怎么写呢?
如:
If color_mohu(x,y,30,30 ...
eett01 发表于 2011-5-25 02:29
举一反三很重要,理解很重要
$color = PixelGetColor(100,100)
If color_mohu($color,30,30,30,20) Then
MsgBox( 0,0,"颜色与30,30,30这个颜色很接近,红绿蓝3个色都分别在20个颜色范围内")
Else
MsgBox(0,0,"颜色不接近")
EndIf
Func color_mohu($$dui_bi_color, $red,$green,$blue,$zhi)
;~ $red = BitAND(BitShift($color, 16), 0xFF)
;~ $green = BitAND(BitShift($color, 8), 0xFF)
;~ $blue = BitAND($color, 0xFF)
$redb = BitAND(BitShift($dui_bi_color, 16), 0xFF)
$greenb = BitAND(BitShift($dui_bi_color, 8), 0xFF)
$blueb = BitAND($dui_bi_color, 0xFF)
If ($red > $redb - $zhi) And ($red < $redb+ $zhi) _
And ($green > $greenb - $zhi) And ($green < $greenb + $zhi) _
And ($blue > $blueb - $zhi) And ($blue < $blueb + $zhi) _
Then
Return True
EndIf
Return False
EndFunc ;==>color_mohu
|