private bool IsFieldBorderSafe(int x, int y, MapElementStatus[,] map, MapElementStatus status) { if (x < 0 || y < 0 || x > map.GetUpperBound(Constants.XDimension) || y > map.GetUpperBound(Constants.YDimension)) { return false; } return map[x, y] == status; }
public static void StoreAsBitmap(string path, MapElementStatus[,] data) { var bitmap = new Bitmap(data.GetUpperBound(0), data.GetUpperBound(1)); for (int x = 0; x < data.GetUpperBound(0); x++) { for (int y = 0; y < data.GetUpperBound(1); y++) { bitmap.SetPixel(x, y, ColorCode[data[x, y]]); } } // bitmap.Save(path); }
/// <summary> /// Will detect all edges with in the area, but ignore the outer most pixels. /// </summary> /// <param name="map">2D Array of MapElementStatus.</param> /// <returns>List of Edge Points.</returns> public List<Point> GetEdgePoints(MapElementStatus[,] map) { List<Point> edgePoints = new List<Point>(); for (var x = 1; x <= map.GetUpperBound(Constants.XDimension) - 2; x++) { for (var y = 1; y <= map.GetUpperBound(Constants.YDimension) - 2; y++) { if (map[x, y] == MapElementStatus.Discovered && IsEdgeField(x, y, map)) { edgePoints.Add(new Point(x, y)); } } } return edgePoints; }