在我的代码中,我得到给定坐标的像素颜色,然后检查颜色是否与另一种颜色匹配。它很好用,现在我希望能够检查它是否在10色左右的颜色或一定数量的色调内匹配。我不知道如何做到这一点。下面是代码:试图获得10色内的颜色值
Public Function GetPixelColor(ByVal x As Integer, ByVal y As Integer) As Color
Dim sz As New Size(1, 1)
Dim c As Color
Using bmp As New Bitmap(1, 1)
Using g As Graphics = Graphics.FromImage(bmp)
g.CopyFromScreen(New Point(x, y), Point.Empty, sz)
c = bmp.GetPixel(0, 0)
End Using
End Using
Return c
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim fb As Color = GetPixelColor(TextBox1.Text, TextBox2.Text)
If fb.ToArgb() = TextBox3.Text Then
MessageBox.Show("Rock on dude")
End If
End Sub
阴影中混合有黑色的颜色,以降低亮度,这是你是什么意思? – Aesthete
根本没有。我的意思是色彩的深浅。 – user1632018
好吧,你说的是_hue_,而不是阴影。因为阴影是黑色的混合物,而颜色不变。 – Aesthete