Hey,
I have a for loop that compares two images. It is checking whether two images of the same size are identical.

for (x = 0; x < imageWidth; x++)
{
    for (y = 0; y < imageHeight; y++)
    {
        If pixels do not match etc.
            {
                Match = false;
                break;
            }
    }
    If (Match == false)
        break;
}

So this works. If the images are identical it will run through the whole script. But here's where I wonder whether there will be an improvement.

for (int _x = 0; _x < 8; _x++)
{
    for (int _y = 0; _y < 8; _y++)
    {
        for (int x = _x; x < imageWidth; x += 8)
        {
            for (int y = _y; y < imageHeight; y += 8)
            {
                if pixels do not match etc.
                    {
                        Match = false;
                        break;
                    }
            }
            if (Match == false)
                break;
        }
        if (Match == false)
            break;
    }
    if (Match == false)
        break;
}

So for those who do not understand that wall of text, rather than checking each pixel one-by-one, it will check them in jumps, as it is more likely that changes will be spread out. For example, if you have a screenshot, and the same screenshot with something added in the bottom right hand corner, the original would read most of the image before spotting it. Providing the artefact is small enough, my script will pick it up quicker.
The question, do these for loops slow it down, and will they slow it down enough to make this alteration worthless or a burden?
Thanks.

An addition to this question, would there be a simple way to make the values of the _#s go like 0, 4, 2, 6 etc? Again, just another thought on speed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.