コード例 #1
0
        // Token: 0x0600003E RID: 62 RVA: 0x00003B2C File Offset: 0x0000272C
        public static TM2 ReadBinary(string fileName)
        {
            TM2 tm = new TM2();

            using (StreamHelper streamHelper = new StreamHelper(fileName, ByteEncoding.Little, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
            {
                tm.Header        = Header.Read(streamHelper);
                tm.PaletteBlocks = new List <PaletteBlock>();
                tm.TextureBlocks = new List <TextureBlock>();
                for (int i = 0; i < (int)tm.Header.CountPalette; i++)
                {
                    tm.PaletteBlocks.Add(PaletteBlock.Read(streamHelper));
                }
                for (int j = 0; j < (int)tm.Header.CountTextures; j++)
                {
                    tm.TextureBlocks.Add(TextureBlock.Read(streamHelper));
                }
            }
            return(tm);
        }
コード例 #2
0
 // Token: 0x06000025 RID: 37 RVA: 0x00003668 File Offset: 0x00002268
 private static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         return;
     }
     if (args[0] == "-e")
     {
         TM2    tm       = TM2.ReadBinary(args[1]);
         string filename = args[1] + ".png";
         string value;
         if (!tm.Validate(out value))
         {
             Console.WriteLine(value);
             filename = args[1] + ".ERROR.png";
         }
         tm.GetImage(null, null).Save(filename, ImageFormat.Png);
     }
     if (args[0] == "-r")
     {
         TM2    tm2 = TM2.ReadBinary(args[1]);
         string str;
         if (!tm2.Validate(out str))
         {
             Console.WriteLine("Repack error: " + str);
             return;
         }
         if (!File.Exists(args[1] + ".png"))
         {
             Console.WriteLine("Repack error: file " + args[1] + ".png not found");
             return;
         }
         Bitmap image = (Bitmap)Image.FromFile(args[1] + ".png");
         tm2.SetImage(image);
         tm2.Save(args[1]);
     }
 }