// Replace button private void button2_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Properties.Settings.Default.texLoadPath; if (openFileDialog1.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.texLoadPath = Path.GetDirectoryName(openFileDialog1.FileName); Properties.Settings.Default.Save(); bool result = GhgManager.OverwriteTexture(selected, ghg, currentGhgPath, openFileDialog1.FileName); if (result) { MessageBox.Show("Successfully replaced texture!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to replace texture.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadTexturesFromGhg(currentGhgPath); int i = 0; foreach (ImagePanelWithDetails imgPanel in panel1.Controls.OfType <ImagePanelWithDetails>()) { if (i == selected) { imgPanel.SetSelected(true); pictureBox1.Image = imgPanel.pictureBox.Image; } i++; } }
// Apply other character copy private void button4_Click(object sender, EventArgs e) { GHGParameters l_ghg; GhgManager.LoadModel(Program.paths.PATH_STUFF + @"\ICONS\" + comboBox1.Text + ".GSC", out l_ghg); bool result = GhgManager.OverwriteTextureData(0, ghg, currentIconPath, l_ghg.texData[0]); if (result) { MessageBox.Show("Successfully replaced texture!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to replace texture.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadIconFromGsc(currentIconPath); }
public void LoadIconFromGsc(string path) { currentIconPath = path; GhgManager.LoadModel(path, out ghg); using (Stream s = new MemoryStream(ghg.texData[0])) { using (Pfim.IImage img = Pfim.Pfim.FromStream(s)) { GCHandle handle = GCHandle.Alloc(img.Data, GCHandleType.Pinned); IntPtr data = Marshal.UnsafeAddrOfPinnedArrayElement(img.Data, 0); Bitmap bitmap = new Bitmap(img.Width, img.Height, img.Stride, System.Drawing.Imaging.PixelFormat.Format32bppArgb, data); pictureBox1.Image = bitmap; pictureBox3.Image = bitmap; label3.Text = "File name: " + Path.GetFileName(path) + "\nDimensions: " + img.Width + "x" + img.Height + "\nDDS file size: " + ghg.texSizes[0] + " bytes (" + ghg.texSizes[0] / 1024 + " KB)\nMipmap count: " + img.MipMaps.Length; handle.Free(); } } }
// Replace button private void button2_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Properties.Settings.Default.iconLoadPath; if (openFileDialog1.ShowDialog() == DialogResult.OK) { Properties.Settings.Default.iconLoadPath = Path.GetDirectoryName(openFileDialog1.FileName); Properties.Settings.Default.Save(); bool result = GhgManager.OverwriteTexture(0, ghg, currentIconPath, openFileDialog1.FileName); if (result) { MessageBox.Show("Successfully replaced texture!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Failed to replace texture.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadIconFromGsc(currentIconPath); } }
public void LoadTexturesFromGhg(string path) { currentGhgPath = path; GhgManager.LoadModel(path, out ghg); panel1.Controls.Clear(); for (int i = 0; i < ghg.texCount; i++) { using (Stream s = new MemoryStream(ghg.texData[i])) { using (Pfim.IImage img = Pfim.Pfim.FromStream(s)) { GCHandle handle = GCHandle.Alloc(img.Data, GCHandleType.Pinned); IntPtr data = Marshal.UnsafeAddrOfPinnedArrayElement(img.Data, 0); Bitmap bitmap = null; if (img.Format == Pfim.ImageFormat.Rgb24) { bitmap = new Bitmap(img.Width, img.Height, img.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, data); } else if (img.Format == Pfim.ImageFormat.Rgba32) { bitmap = new Bitmap(img.Width, img.Height, img.Stride, System.Drawing.Imaging.PixelFormat.Format32bppArgb, data); } ImagePanelWithDetails imgPanel = new ImagePanelWithDetails(); imgPanel.pictureBox.Image = bitmap; imgPanel.label.Text = "Texture #" + i + "\nDimensions: " + ghg.texWidths[i] + "x" + ghg.texHeights[i]; imgPanel.label.MouseClick += Details_MouseClick; imgPanel.pictureBox.MouseClick += Details_MouseClick; imgPanel.Location = new Point(4, 4 + i * 65); imgPanel.MouseClick += ImgPanel_MouseClick; panel1.Controls.Add(imgPanel); handle.Free(); } } } imgDetailsPanel.Hide(); }