SHOW:
|
|
- or go back to the newest paste.
| 1 | using System; | |
| 2 | using System.Collections.Generic; | |
| 3 | using System.Linq; | |
| 4 | using System.Text; | |
| 5 | using System.IO; | |
| 6 | using System.Drawing; | |
| 7 | ||
| 8 | namespace SalemMapper | |
| 9 | {
| |
| 10 | class MainClass | |
| 11 | {
| |
| 12 | static void Main(String[] args) | |
| 13 | {
| |
| 14 | - | // Create a reference to the current directory. |
| 14 | + | |
| 15 | FileInfo[] fi = di.GetFiles(); | |
| 16 | - | // Create an array representing the files in the current directory. |
| 16 | + | |
| 17 | foreach (FileInfo fiTemp in fi) | |
| 18 | - | // Print out the names of the files in the current directory. |
| 18 | + | |
| 19 | if(fiTemp.Name.StartsWith("tile")){
| |
| 20 | String s1 = fiTemp.Name.Substring(fiTemp.Name.IndexOf('_') + 1, fiTemp.Name.LastIndexOf('_') - fiTemp.Name.IndexOf('_') - 1);
| |
| 21 | int x = Convert.ToInt32(s1); | |
| 22 | int i1 = fiTemp.Name.LastIndexOf('_') + 1;
| |
| 23 | int i2 = fiTemp.Name.IndexOf('.') - fiTemp.Name.LastIndexOf('_') - 1;
| |
| 24 | String s2 = fiTemp.Name.Substring(i1, i2); | |
| 25 | int y = Convert.ToInt32(s2); | |
| 26 | if (minx > x) minx = x; | |
| 27 | if (maxx < x) maxx = x; | |
| 28 | if (miny > y) miny = y; | |
| 29 | if (maxy < y) maxy = y; | |
| 30 | } | |
| 31 | } | |
| 32 | ||
| 33 | FileInfo[,] fis = new FileInfo[maxx - minx + 1, maxy - miny + 1]; | |
| 34 | foreach (FileInfo fiTemp in fi) | |
| 35 | {
| |
| 36 | if(fiTemp.Name.StartsWith("tile")){
| |
| 37 | String s1 = fiTemp.Name.Substring(fiTemp.Name.IndexOf('_') + 1, fiTemp.Name.LastIndexOf('_') - fiTemp.Name.IndexOf('_') - 1);
| |
| 38 | int x = Convert.ToInt32(s1); | |
| 39 | int i1 = fiTemp.Name.LastIndexOf('_') + 1;
| |
| 40 | int i2 = fiTemp.Name.IndexOf('.') - fiTemp.Name.LastIndexOf('_') - 1;
| |
| 41 | String s2 = fiTemp.Name.Substring(i1, i2); | |
| 42 | int y = Convert.ToInt32(s2); | |
| 43 | ||
| 44 | fis[x - minx, y - miny] = fiTemp; | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| 48 | Bitmap b = new Bitmap((maxx - minx + 1)*100, (maxy - miny +1)*100); | |
| 49 | for (int i = 0; i < fis.GetLength(0); i++) | |
| 50 | {
| |
| 51 | for (int j = 0; j < fis.GetLength(1); j++) | |
| 52 | {
| |
| 53 | try | |
| 54 | {
| |
| 55 | Bitmap bt = new Bitmap(fis[i, j].Name); | |
| 56 | Graphics g = Graphics.FromImage(b); | |
| 57 | g.DrawImage(bt, new Point(i * 100, j * 100)); | |
| 58 | }catch(Exception){
| |
| 59 | ||
| 60 | } | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | b.Save("mapped.png");
| |
| 65 | } | |
| 66 | } | |
| 67 | } |