| 45 | } |
| 46 | |
| 47 | public static void Main(string[] args) |
| 48 | { |
| 49 | if (args.Length < 2) usage(); |
| 50 | |
| 51 | try |
| 52 | { |
| 53 | mapObj map = new mapObj(args[0]); |
| 54 | |
| 55 | using(imageObj image = map.draw()) |
| 56 | { |
| 57 | // solution 1 |
| 58 | Console.WriteLine ("Drawing map: '" + map.name + "' using imageObj.getBytes"); |
| 59 | |
| 60 | byte[] img = image.getBytes(); |
| 61 | using (MemoryStream ms = new MemoryStream(img)) |
| 62 | { |
| 63 | Image mapimage = Image.FromStream(ms); |
| 64 | mapimage.Save(args[1]); |
| 65 | } |
| 66 | |
| 67 | // solution 2 |
| 68 | Console.WriteLine ("Drawing map: '" + map.name + "' using imageObj.write"); |
| 69 | |
| 70 | using (FileStream fs = File.Open("_" + args[1], FileMode.OpenOrCreate, FileAccess.ReadWrite)) |
| 71 | { |
| 72 | image.write(fs); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | catch (Exception ex) |
| 77 | { |
| 78 | Console.WriteLine( "GetBytes: ", ex.Message ); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | } |
| 83 | |