I'm trying to implement a function that will scan the computer screen for a given image of an icon and get its coordinates.
Since the image of the icon will be taken by me I thought it would be best not to use any image recognition technique but rather byte comparison, thinking if I take a screenshot of the screen, while the icon is visible, I will cut just the icon, save it as *.bmp and then instruct the program to take a Bitmap
screenshot, convert it and the icon image to a byte array and look for one in the other and, perhaps, by the location of the bytes of the icon image in the screenshot determine where on the screen it is.
I fail at step 1, which is - use the "Prt Scr" button to take a screenshot, save it as *.bmp then copy the part with the icon (in this case The Start Button), save only that as *.bmp separately and then use the ImageConverter
class to convert them both into byte arrays and look for one in the other.
Initially I've tried most all the answers from this question but they all failed to find it. Then I got a StringBuilder
and iterated through each array, appending each element to the StringBuilder
with a comma after it. Then I copied both results to Notepad++ and searched for the Start Button bytes in the full screenshot. They aren't there.
So I wonder why the bytes wouldn't be there, considering one is a direct copy of a smaller section of the bigger picture and, two - is my approach to find the coordinates of a smaller image inside a larger one by using byte comparison wrong?
EDIT: Removed code as it doesn't matter in this case.