I am scanning the screen for a button to click using the code below.
I pass in two bitmaps one is a picture of the button the other is a screenshot.
Is there anyway I can speed this basic method up?
private PositionToClick IsInCapture(Bitmap searchFor, Bitmap searchIn)
{
for (int x = 0; x < searchIn.Width; x++)
{
for (int y = 0; y < searchIn.Height; y++)
{
bool invalid = false;
int k = x, l = y;
for (int a = 0; a < searchFor.Width; a++)
{
l = y;
for (int b = 0; b < searchFor.Height; b++)
{
if (searchFor.GetPixel(a, b) != searchIn.GetPixel(k, l))
{
invalid = true;
break;
}
else
l++;
}
if (invalid)
break;
else
k++;
}
if (!invalid)
return new PositionToClick() { X = x, Y = y, found = true };
}
}
return new PositionToClick();
}