public static OpenDTO importFile(String name) { int[,] result = null; StreamReader reader = new StreamReader(name); String line = reader.ReadLine(); int width = int.Parse(line.Split(' ')[0]); int height = int.Parse(line.Split(' ')[1]); List <int[]> list = new List <int[]>(); while ((line = reader.ReadLine()) != null) { String[] values = line.Trim().Split(' '); int[] tmp = new int[width]; for (int c = 0; c < width; c++) { tmp[c] = int.Parse(values[c]); } list.Add(tmp); } result = new int[list.Count, width]; for (int row = 0; row < list.Count; row++) { for (int col = 0; col < width; col++) { result[row, col] = list[row][col]; } } return(OpenDTO.create(result, width, height)); }
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); }