public Bitmap DisplayMap(MapElement level, List <Backdrop> backdrops, Rectangle bounds, bool before) { if (Tiles.Columns == 0 || Tiles.Rows == 0) { return(null); } Bitmap img = new Bitmap(Tiles.Columns * Width, Tiles.Rows * Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(img)) { if (before) { using (SolidBrush brush = new SolidBrush(DefaultBackground)) { g.FillRectangle(brush, 0, 0, img.Width, img.Height); } if (backdrops != null) { for (int i = 0; i < backdrops.Count; i++) { Backdrop bd = backdrops[i]; if (level == null || bd.IsVisible(level.Attr("name"))) { bd.Render(bounds, g); } } } } for (int i = 0; i < Tiles.Columns; i++) { for (int j = 0; j < Tiles.Rows; j++) { Bitmap tile = Tiles[i, j]; if (tile != null) { g.DrawImage(tile, (float)i * Width, (float)j * Height); } } } if (!before && backdrops != null) { for (int i = 0; i < backdrops.Count; i++) { Backdrop bd = backdrops[i]; if (level == null || bd.IsVisible(level.Attr("name"))) { bd.Render(bounds, g); } } } } return(img); }