private IEnumerable<Point> GetMatchingUnprocessedDirectNeighbors(int x, int y)
{
var directNeighbors = new List<Point>();
// top
int newX = x;
int newY = y - 1;
if (newY > 0 && !this._colorsProcessed[newX, newY] && this._colors[x, y] == this._colors[newX, newY])
{
directNeighbors.Add(new Point { X = newX, Y = newY });
}
// right
newX = x + 1;
newY = y;
if (newX < this._bitmapWidth && !this._colorsProcessed[newX, newY] && this._colors[x, y] == this._colors[newX, newY])
{
directNeighbors.Add(new Point { X = newX, Y = newY });
}
// bottom
newX = x;
newY = y + 1;
if (newY < this._bitmapHeight && !this._colorsProcessed[newX, newY] && this._colors[x, y] == this._colors[newX, newY])
{
directNeighbors.Add(new Point { X = newX, Y = newY });
}
// left
newX = x - 1;
newY = y;
if (newX > 0 && !this._colorsProcessed[newX, newY] && this._colors[x, y] == this._colors[newX, newY])
{
directNeighbors.Add(new Point { X = newX, Y = newY });
}
return directNeighbors;
}