static void Main(string[] args) { Console.WriteLine("TMXConv for King's Field IV (The Ancient City)\n"); if (args.Length < 1) { Console.WriteLine("Usage:\nTMXConv.exe f.tmx\n"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } //Get Write Path string writePath = Path.GetDirectoryName(args[0]) + "\\"; string writeName = Path.GetFileNameWithoutExtension(args[0]); //Reading TMX Header using (InputStream ins = new InputStream(args[0])) { //Read Rough Header uint totalSize = ins.ReadUInt32(); uint totalTM2s = ins.ReadUInt32(); ins.ReadUInt32(); ins.ReadUInt32(); //Read Image Reference for (uint i = 0; i < totalTM2s; ++i) { uint tm2Offset = ins.ReadUInt32(); ins.ReadUInt32(); ins.ReadUInt32(); ins.ReadUInt32(); ins.Jump(tm2Offset); uint tm2Size = ins.ReadUInt32(); ins.Seek(-4, SeekOrigin.Current); TM2 tm2 = TM2.FromMemory(ins.ReadBytes((int)tm2Size)); tm2.Save(writePath + writeName + "_" + i.ToString("D4") + ".png"); ins.Return(); } } }
static void Main(string[] args) { Console.WriteLine("TM2toPNG for King's Field IV (The Ancient City)\n"); if (args.Length < 1) { Console.WriteLine("Usage:\nTM2toPNG.exe f.tm2\n"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } //Get Write Path string writePath = Path.GetDirectoryName(args[0]) + "\\"; string writeName = Path.GetFileNameWithoutExtension(args[0]); //Open TM2 Console.WriteLine("Reading TM2..."); TM2 tm2 = TM2.FromFile(args[0]); if (tm2 == null) { Console.WriteLine("Failed to read TM2"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } //Save PNG Console.WriteLine("Writing PNG..."); tm2.Save(writePath + writeName); //Finished Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }