# Thread: finding the screen coordinates of a pixel

1. ## finding the screen coordinates of a pixel

i have an image that has white pixels in it, the image is at the size of my screen, 1024x768, and i want to find the x and y coordinates of every white pixel.
how can it be done?

2. a not so elegant way would be to do a nested loop to represent x and y then do an if on each pixel at that position. you would probably want to store it in memory on a bmp first then traverse the pixels. like i said, not elegant but will get you a temp fix while you dig into the graphics stuff.

Thats usually how i start, the quickest dirtiest way and pick up all the other techniques on the way to make it something nice.

i thought, since the picture is at the size of my screen, i would get the screen coordinates like that, but i didn't.
i get some weird coordinates with minuses and such, dunno why...

4. Are you capturing the screen and storing it into a temporary BITMAP and then doing something like this:

Code:
```Color pureWhite = Color.FromArgb(255,255,255);
for (x = 0; x < bmap.Width; x++)
{
for (y = 0; y < bmap.Height; y++)
{
if (bmap.GetPixel(x, y) == pureWhite)
{
//do code whatever
}
}
}```
Do you have any code, what have you tried?

5. I can't think of a more elegant solution than the given one. It's short and clear. Given that there is no knowledge about the image, there's no special knowledge that you can use to, e.g., skip parts of the image, which would be the only way of making it faster.

6. well, you could grab it down then tell it to squeeze it into a forth of its size. Once squeezed, run through each pixel looking for an averaged out white and not the quadrant its in, then go back to your primary image and get the actual locations.

doing it that way, you would possibly not catch every single pixel that was white since the compression to smaller size would average areas. But, you would most likely have less area to scan. If you wanted to catch small white area, its more likely to miss them using this method and a full scan would be the best way.

Do you have to know the locations of the white pixels for reporting or are you just converting them or what?

7. The squeezing would take longer than just scanning the entire image.

8. oh, lol, my original code eventually worked, i had a stupid calculation mistake...
thank you guys!