private void DrawRectangles(Rectangle?[,] rectangles, Graphics g) { int w = Controller.TileSize.Width; int h = Controller.TileSize.Height; for (int y = 0; y < rectangles.GetLength(1); y++) { for (int x = 0; x < rectangles.GetLength(0); x++) { var dest = new Rectangle(x * w, y * h, w, h); var src = rectangles[x, y]; if (src != null) g.DrawImage(_image, dest, (Rectangle)src, GraphicsUnit.Pixel); } } }