private void button30_Click(object sender, EventArgs e) { Scene s = Scene.FromFile("test.lev"); s.ctrvram.SaveBMP("before.bmp", BMPHeader.GrayScalePalette(16)); s.ctrvram = new Tim(new Rectangle(0, 0, 1024, 512)); foreach (var t in s.GetTexturesList()) { if (File.Exists("test\\" + t.Value.Tag() + ".tim")) { try { s.ctrvram.DrawTim(Tim.FromFile("test\\" + t.Value.Tag() + ".tim")); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } s.ctrvram.SaveBMP("after.bmp", BMPHeader.GrayScalePalette(16)); MessageBox.Show("done"); }
private void button8_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "CTR VRAM file|*.vrm"; if (ofd.ShowDialog() == DialogResult.OK) { Tim buf = CtrVrm.FromFile(ofd.FileName); MessageBox.Show(buf.data.Length / 256 + ""); if (scn != null) { Dictionary <string, TextureLayout> tex = scn.GetTexturesList(); MessageBox.Show(tex.Count.ToString()); foreach (TextureLayout tl in tex.Values) { //buf.GetTexturePage(tl, ""); } } buf.SaveBMP("test.bmp", BMPHeader.GrayScalePalette(16)); //buf.palbmp.Save("palletes.png", System.Drawing.Imaging.ImageFormat.Png); //Process.Start("palletes.png"); } }
private void button18_Click_1(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "CTR VRAM file|*.vram"; if (ofd.ShowDialog() == DialogResult.OK) { Tim buf = CtrVrm.FromFile(ofd.FileName); Bitmap bmp = new Bitmap(160, 80); Graphics g = Graphics.FromImage(bmp); using (BinaryReaderEx br2 = new BinaryReaderEx(File.Open("ui_map", FileMode.Open))) { int z = br2.ReadInt32(); List <TexMap> list = new List <TexMap>(); for (int i = 0; i < 50; i++) { list.Add(new TexMap(br2)); } int x = 0; int y = 0; foreach (TexMap map in list) { buf.GetTexture(map.tl, "tex", map.name); Bitmap b = (Bitmap)Bitmap.FromFile("tex" + "\\" + map.name + ".png"); g.DrawImage(b, x * 16, y * 16); x++; if (x >= 10) { x = 0; y++; } } bmp.Save("font.png", System.Drawing.Imaging.ImageFormat.Png); } /* * Dictionary<string, TextureLayout> tex = scn.GetTexturesList(); * MessageBox.Show(tex.Count.ToString()); * } */ buf.SaveBMP("test.bmp", BMPHeader.GrayScalePalette(16)); //buf.palbmp.Save("palletes.png", System.Drawing.Imaging.ImageFormat.Png); Process.Start("font.png"); } }
private void actionExtract_Click(object sender, EventArgs e) { if (!File.Exists(pathFile.Text)) { MessageBox.Show($"File doesn't exist!\r\n{pathFile.Text}"); return; } using (Scene s = Scene.FromFile(pathFile.Text)) { if (optionTexHigh.Checked) { s.ExportTextures(Path.Combine(pathFileParent, "texHigh"), Detail.High); } if (optionTexMed.Checked) { s.ExportTextures(Path.Combine(pathFileParent, "texMed"), Detail.Med); } if (optionTexLow.Checked) { s.ExportTextures(Path.Combine(pathFileParent, "texLow"), Detail.Low); } if (optionTexModels.Checked) { s.ExportTextures(Path.Combine(pathFileParent, "texModels"), Detail.Models); } //generates colored vram, keep in mind same texture data may use different palettes Bitmap bmp = new Bitmap(2048, 512); Graphics g = Graphics.FromImage(bmp); foreach (var x in s.GetTexturesList()) { using (Bitmap bb = s.ctrvram.GetTexture(x.Value)) { if (bb != null) { g.DrawImage(bb, x.Value.RealX * 4 - 2048, x.Value.RealY); } } } bmp.Save(Path.Combine(pathFileParent, "test_color.bmp")); s.ctrvram.SaveBMP(Path.Combine(pathFileParent, "test_bw.bmp"), BMPHeader.GrayScalePalette(16)); } GC.Collect(); MessageBox.Show("Done!"); }
private void actionPack_Click(object sender, EventArgs e) { if (!File.Exists(pathFile.Text)) { MessageBox.Show($"File doesn't exist!\r\n{pathFile.Text}"); return; } using (Scene scn = Scene.FromFile(pathFile.Text)) { Tim ctr = scn.ctrvram; //dumping vram before the change if (optionDebugVram.Checked) { //only dump if file doesn't exist (to compare to earliest version of vram) if (!File.Exists(Path.Combine(pathFileParent, "test_old.bmp"))) { ctr.SaveBMP(Path.Combine(pathFileParent, "test_old.bmp"), BMPHeader.GrayScalePalette(16)); } } Dictionary <string, TextureLayout> list = scn.GetTexturesList(); foreach (string s in Directory.GetFiles(pathFolder.Text, "*.png")) { string tag = Path.GetFileNameWithoutExtension(s); Console.Write($"replacing {tag}... "); if (!list.ContainsKey(tag)) { Helpers.Panic(ctr, "unknown texture entry"); continue; } Tim newtex = ctr.GetTimTexture(list[tag]); newtex.LoadDataFromBitmap(s); ctr.DrawTim(newtex); Console.WriteLine("done."); } if (optionDebugVram.Checked) { ctr.SaveBMP(Path.Combine(pathFileParent, "test_new.bmp"), BMPHeader.GrayScalePalette(16)); } List <Tim> tims = new List <Tim>(); foreach (var r in CtrVrm.frames) { tims.Add(ctr.GetTrueColorTexture(r)); } string tempFile = Path.Combine(pathFileParent, "temp.tim"); string vramFile = Path.ChangeExtension(pathFile.Text, ".vrm"); Helpers.BackupFile(vramFile); File.Delete(vramFile); using (BinaryWriterEx bw = new BinaryWriterEx(File.Create(vramFile))) { bw.Write((int)0x20); foreach (Tim tim in tims) { tim.Write(tempFile); byte[] x = File.ReadAllBytes(tempFile); bw.Write(x.Length); bw.Write(x); } bw.Write((int)0); bw.Flush(); bw.Close(); } File.Delete(tempFile); //ctr.GetTrueColorTexture(512, 0, 384, 256).Write(Path.Combine(Path.GetDirectoryName(pathFolder.Text), "x01.tim")); //ctr.GetTrueColorTexture(512, 256, 512, 256).Write(Path.Combine(Path.GetDirectoryName(pathFolder.Text), "x02.tim")); } GC.Collect(); MessageBox.Show("Done."); }