private void DrawTileMap(DevicePanel d, int x, int y, int platform_x, int platform_y, int platform_width, int platform_height, int transparency) { if (ScatchLayer != null) { if (TileMap == null || TileMap != ScatchLayer.Tiles || TilesNeedUpdate || PlatformImage == null) { TilesNeedUpdate = false; if (PlatformImage != null) { PlatformImage.Dispose(); PlatformImage = null; } TileMap = ScatchLayer.Tiles; var bitmap = new System.Drawing.Bitmap(ScatchLayer.Width * Methods.Solution.SolutionConstants.TILE_SIZE, ScatchLayer.Height * Methods.Solution.SolutionConstants.TILE_SIZE); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap); ScatchLayer.Draw(g); PlatformImage = Methods.Drawing.TextureCreator.FromBitmap(d._device, bitmap); g.Clear(System.Drawing.Color.Transparent); bitmap.Dispose(); g.Dispose(); } d.DrawBitmap(PlatformImage, x, y, platform_x, platform_y, platform_width, platform_height, false, transparency); } }
private bool DrawTileMap(DevicePanel d, int _x, int _y, int transparency, System.Drawing.Color color) { if (ErrorKilled) { return(false); } try { int x = _x - (platform_width / 2); int y = _y - (platform_height / 2); if (MoveLayer != null) { if (TileMap == null || TileMap != MoveLayer.Tiles || TilesNeedUpdate || PlatformImage == null) { TilesNeedUpdate = false; if (PlatformImage != null) { PlatformImage.Dispose(); PlatformImage = null; } TileMap = MoveLayer.Tiles; var bitmap = new System.Drawing.Bitmap(MoveLayer.Width * Methods.Solution.SolutionConstants.TILE_SIZE, MoveLayer.Height * Methods.Solution.SolutionConstants.TILE_SIZE); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap); MoveLayer.Draw(g); PlatformImage = Methods.Drawing.TextureCreator.FromBitmap(d._device, bitmap); g.Clear(System.Drawing.Color.Transparent); bitmap.Dispose(); g.Dispose(); } d.DrawBitmap(PlatformImage, x, y, platform_x, platform_y, platform_width, platform_height, false, transparency, false, false, 0, color); } return(true); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); ErrorKilled = true; return(false); } }