我有一个关于颜色检测的问题。我有代码,但我想要多个结果。代码很有名,但我想让程序为我带来所有结果,而不仅仅是一个结果。我希望我明确自己。C#颜色检测多个结果
我的坏我所做的漏抄
private Boolean FindBitmap(Bitmap bmpNeedle, Bitmap bmpHaystack, out Point location)
{
try
{
for (int outerX = 0; outerX < bmpHaystack.Width - bmpNeedle.Width; outerX++)
{
for (int outerY = 0; outerY < bmpHaystack.Height - bmpNeedle.Height; outerY++)
{
for (int innerX = 0; innerX < bmpNeedle.Width; innerX++)
{
for (int innerY = 0; innerY < bmpNeedle.Height; innerY++)
{
Color cNeedle = bmpNeedle.GetPixel(innerX, innerY);
Color cHaystack = bmpHaystack.GetPixel(innerX + outerX, innerY + outerY);
if (cNeedle.R != cHaystack.R || cNeedle.G != cHaystack.G || cNeedle.B != cHaystack.B)
{
goto notFound;
}
}
}
location = new Point(outerX, outerY);
listBox1.Items.Add(location);
MessageBox.Show(location.ToString());
notFound:
continue;
}
}
}
catch (Exception)
{
}
location = Point.Empty;
return false;
}
_“该代码是着名的”_?你是什么意思? – Nat
https://www.youtube.com/watch?v=gEgxZrXPnzc – Agrael
Youtube的名气不是真正的名气。对于代码,它甚至不是stackoverflow.com的名气,也不是真正的名声。 –