I'm using GetPixel to get the colour of each pixel of an image. The images contain different plain-coloured irregular shapes, and I'd like to find the point (or pixel) where the maximum width matches the maximum height (see figure below).
(disregard the border)
I'm using this to iterate through the captured bitmap:
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
Color clr = bmp.GetPixel(x, y);
// Hit
if (TestColour(clr)) // See if we're within the shape. I'm just comparing a bunch of colours here.
{
// Stuff I don't know
}
}
}
I got it to work by using a hashTable, but I understand that it's an dawful solution. I was thinking in the lines of just having two integers (one for X, one for Y) increment and save the maximum value for each iteration, then compare this to the previous one and replace the value if it's higher.
I don't see how I'd be able to use that approach with my for-loops nested like that.
Any input?