public void save(String name) { try { List <Tile> tiles = worldmap.Children; int count = worldmap.Children.Count; Bitmap bg = new Bitmap(count * 16, 16); using (Graphics g = Graphics.FromImage(bg)) { for (int c = 0; c < count; c++) { Bitmap tmp = Utils.convertMatrixColorPixelToBitmap(tiles[c].Matrix, 16, 16); g.DrawImage(tmp, new Point(c * 16, 0)); } } UtilsFile.exportFile(name + ".txt", worldmap.Matrix_save, this.col_map, this.row_map); bg.Save(name + ".png"); bg.Dispose(); } catch (Exception ex) { } }
public Bitmap open(String name) { OpenDTO open = UtilsFile.importFile(name + ".txt"); int[,] matrix_map = open.Matrix; Bitmap tmp = new Bitmap(name + ".png"); int width = tmp.Width; int height = tmp.Height; this.col_map = open.Col_map; this.row_map = open.Row_map; int col = width / 16; int row = height / 16; ColorPixel[,] mt = Utils.convertBitmapToColorPixel(tmp); WorldMap wm = WorldMap.create(mt, width, height); wm.createTiles(); List <Tile> list = wm.Children; worldmap = WorldMap.restore(matrix_map, list, this.col_map, this.row_map); worldmap.createTiles(); Tile[,] tiles = worldmap.Tiles; Bitmap rs = Utils.convertTilesToBitmap(tiles, this.row_map, this.col_map); return(rs); }