public static Mask FromText(string file) { string[] lines = File.ReadAllLines(file); int rows = lines.Length; int columns = lines[0].Length; var mask = new Mask(rows, columns); for (int x = 0; x < rows; x++) { for (int y = 0; y < columns; y++) { if (lines[x][y] == 'X') { mask[x, y] = false; } else { mask[x, y] = true; } } } return mask; }
public static Mask FromImage(string file) { Bitmap image = new Bitmap(System.Drawing.Image.FromFile(file)); var mask = new Mask(image.Height, image.Width); for (int x = 0; x < mask.Rows; x++) { for (int y = 0; y < mask.Columns; y++) { if (image.GetPixel(y, x).ToArgb() == Color.Black.ToArgb()) { mask[x, y] = false; } else { mask[x, y] = true; } } } return mask; }
public MaskedGrid(Mask mask) : base(mask.Rows, mask.Columns) { _mask = mask; PrepareGrid(); ConfigureCells(); }