Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        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();
                }
            }
        }
Esempio n. 3
0
        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();
        }