mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-11 09:24:58 +00:00
Apply Math.Sqrt(templateWidth * templateHeight) < 10.0
This commit is contained in:
parent
9227518d1e
commit
38288153ed
|
@ -551,14 +551,30 @@ public class ScreenMatch
|
|||
int templateHeight = templateImage.Height;
|
||||
int totalPixels = templateWidth * templateHeight;
|
||||
int requiredMatches = (int)(totalPixels * threshold);
|
||||
|
||||
// When the square root of the canvas size of the image to be matched is less than 10, a complete match is applied.
|
||||
if (Math.Sqrt(templateWidth * templateHeight) < 10.0)
|
||||
{
|
||||
for (int y = 0; y < templateHeight; y++)
|
||||
{
|
||||
for (int x = 0; x < templateWidth; x++)
|
||||
{
|
||||
if (mainImage.GetPixel(x + offsetX, y + offsetY) != templateImage.GetPixel(x, y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, randomness is used.
|
||||
int matchedCount = 0;
|
||||
Random rand = new Random();
|
||||
|
||||
while (matchedCount < requiredMatches)
|
||||
{
|
||||
int x = rand.Next(templateWidth);
|
||||
int y = rand.Next(templateHeight);
|
||||
Point point = new Point(x, y);
|
||||
|
||||
if (mainImage.GetPixel(x + offsetX, y + offsetY) != templateImage.GetPixel(x, y))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user