public int Extract(string source_file, string dest_path) { try { Directory.CreateDirectory(dest_path); } catch (Exception) { Console.WriteLine("Error: Cannot prepare destination directory for file writing."); return(-1); } PNGFile png = new PNGFile(); string source_type = null; png.Hsav += delegate(string type) { Console.WriteLine("This is {0} Save File", type); DumpSourceType(dest_path + @"\TDCG.txt", type); source_type = type; string figure_path = dest_path + @"\" + numTMO; if (!System.IO.Directory.Exists(figure_path)) { System.IO.Directory.CreateDirectory(figure_path); } }; png.Pose += delegate(string type) { Console.WriteLine("This is {0} Save File", type); DumpSourceType(dest_path + @"\TDCG.txt", type); source_type = type; }; png.Scne += delegate(string type) { Console.WriteLine("This is {0} Save File", type); DumpSourceType(dest_path + @"\TDCG.txt", type); source_type = type; }; png.Cami += delegate(Stream dest, int extract_length) { byte[] buf = new byte[extract_length]; dest.Read(buf, 0, extract_length); string dest_file = dest_path + @"\Camera.txt"; Console.WriteLine("CAMI Save File: " + dest_file); using (StreamWriter sw = new StreamWriter(dest_file)) for (int offset = 0; offset < extract_length; offset += sizeof(float)) { float flo = BitConverter.ToSingle(buf, offset); sw.WriteLine(flo); } }; png.Lgta += delegate(Stream dest, int extract_length) { numTMO++; byte[] buf = new byte[extract_length]; dest.Read(buf, 0, extract_length); string dest_file = dest_path + @"\LightA" + numTMO + ".txt"; Console.WriteLine("LGTA Save File: " + dest_file); using (StreamWriter sw = new StreamWriter(dest_file)) for (int offset = 0; offset < extract_length; offset += sizeof(float)) { float flo = BitConverter.ToSingle(buf, offset); sw.WriteLine(flo); } }; png.Figu += delegate(Stream dest, int extract_length) { byte[] buf = new byte[extract_length]; dest.Read(buf, 0, extract_length); string dest_file = dest_path + @"\Figure" + numTMO + ".txt"; Console.WriteLine("FIGU Save File: " + dest_file); using (StreamWriter sw = new StreamWriter(dest_file)) for (int offset = 0; offset < extract_length; offset += sizeof(float)) { float flo = BitConverter.ToSingle(buf, offset); sw.WriteLine(flo); } string figure_path = dest_path + @"\" + numTMO; if (!System.IO.Directory.Exists(figure_path)) { System.IO.Directory.CreateDirectory(figure_path); } }; png.Ftmo += delegate(Stream dest, int extract_length) { string dest_file = dest_path + @"\" + numTMO + ".tmo"; Console.WriteLine("TMO Save File: " + dest_file); using (FileStream file = File.Create(dest_file)) { byte[] buf = new byte[4096]; StreamUtils.Copy(dest, file, buf); } }; png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 1; i++) { sb.Append(string.Format("{0:X2}", opt1[i])); } string code = sb.ToString(); string dest_file = dest_path + @"\" + numTMO + @"\" + code + ".tso"; Console.WriteLine("TSO Save File: " + dest_file); using (FileStream file = File.Create(dest_file)) { byte[] buf = new byte[4096]; StreamUtils.Copy(dest, file, buf); } }; png.Load(source_file); png.Save(dest_path + @"\thumbnail.png"); if (source_type == "HSAV") { BMPSaveData data = new BMPSaveData(); using (Stream stream = File.OpenRead(dest_path + @"\thumbnail.png")) data.Read(stream); string dest_file = dest_path + @"\thumbnail.txt"; Console.WriteLine("dump bmp save data: " + dest_file); DumpBmpSaveData(data, dest_file); } return(0); }
public static void Main(string[] args) { if (args.Length != 1) { System.Console.WriteLine("Usage: BMPSaveDataTest <png file>"); return; } string source_file = args[0]; BMPSaveData data = new BMPSaveData(); using (Stream stream = File.OpenRead(source_file)) data.Read(stream); for (int i = 0; i < 32; i++) { Console.WriteLine(data.GetFileName(i)); } #if false for (int i = 0; i < 16; i++) { Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(i), 0)); } #endif Console.WriteLine(data.GetSliderValue(0)); // おっぱい Console.WriteLine(BitConverter.ToUInt32(data.GetBytes(1), 0)); Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(2), 0)); // 固定 Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(3), 0)); // key1 Console.WriteLine(data.GetSliderValue(4)); // 姉妹 Console.WriteLine(data.GetSliderValue(5)); Console.WriteLine(data.GetSliderValue(6)); Console.WriteLine(data.GetSliderValue(7)); // 胴まわり Console.WriteLine(data.GetSliderValue(8)); Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(9), 0)); // 固定 Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(10), 0)); // key2 Console.WriteLine(data.GetSliderValue(11)); Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(12), 0)); // 固定 Console.WriteLine("0x{0:X8}", BitConverter.ToUInt32(data.GetBytes(13), 0)); // key3 Console.WriteLine(""); //data.SetFileName(0, "items/N0010BC1_A01"); // おっぱい float oppai = 0.225f; data.SetSliderValue(0, oppai); Console.WriteLine("oppai {0:F4}", oppai); // 姉妹 float age = 0.5f; data.SetSliderValue(4, age); Console.WriteLine("age {0:F4}", age); data.Save("out.thumbnail.png"); //data.Save("tmp.png"); //PNGFile png = new PNGFile(); //png.Load("tmp.png"); //png.Save("out.tdcgsav.png"); }