public void SetupSettings()
        {
            if (SelectedTexSettings.Format == SurfaceFormat.Invalid)
            {
                return;
            }


            if (Thread != null && Thread.IsAlive)
            {
                Thread.Abort();
            }

            if (formatComboBox.SelectedItem is SurfaceFormat)
            {
                SelectedTexSettings.Format = (SurfaceFormat)formatComboBox.SelectedItem;
                listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString();
            }
            Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage();

            Thread = new Thread((ThreadStart)(() =>
            {
                pictureBox1.Image = bitmap;
                SelectedTexSettings.Compress();

                bitmap = TextureData.DecodeBlock(SelectedTexSettings.DataBlockOutput[0], SelectedTexSettings.
                                                 TexWidth, SelectedTexSettings.TexHeight, SelectedTexSettings.Format);

                pictureBox1.Image = bitmap;
            }));
            Thread.Start();

            //  WidthLabel.Text = $"Width {pictureBox1.Image.Width}";
            //      HeightLabel.Text = $"Height {pictureBox1.Image.Height}";
        }
        public void SetupSettings()
        {
            if (SelectedTexSettings.Format == SurfaceFormat.Invalid)
            {
                return;
            }


            WidthLabel.Text  = $"Width {SelectedTexSettings.TexWidth}";
            HeightLabel.Text = $"Height {SelectedTexSettings.TexHeight}";


            if (formatComboBox.SelectedItem is SurfaceFormat)
            {
                SelectedTexSettings.Format = (SurfaceFormat)formatComboBox.SelectedItem;
                listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString();
            }
            Bitmap bitmap = Switch_Toolbox.Library.Imaging.GetLoadingImage();


            Thread = new Thread((ThreadStart)(() =>
            {
                ToggleOkButton(false);

                pictureBox1.Image = bitmap;
                SelectedTexSettings.Compress();

                ToggleOkButton(true);

                if (SelectedTexSettings.Format == SurfaceFormat.BC5_SNORM)
                {
                    bitmap = DDSCompressor.DecompressBC5(SelectedTexSettings.DataBlockOutput[0],
                                                         (int)SelectedTexSettings.TexWidth, (int)SelectedTexSettings.TexHeight, true);
                }
                else
                {
                    bitmap = TextureData.DecodeBlockGetBitmap(SelectedTexSettings.DataBlockOutput[0],
                                                              SelectedTexSettings.TexWidth, SelectedTexSettings.TexHeight, TextureData.ConvertFormat(SelectedTexSettings.Format));
                }

                if (pictureBox1.InvokeRequired)
                {
                    pictureBox1.Invoke((MethodInvoker) delegate {
                        pictureBox1.Image = bitmap;
                        pictureBox1.Refresh();
                    });
                }
            }));
            Thread.Start();
        }
Example #3
0
        public void SetupSettings()
        {
            if (SelectedTexSettings.Format == TEX_FORMAT.UNKNOWN)
            {
                return;
            }

            if (Thread != null && Thread.IsAlive)
            {
                Thread.Abort();
            }

            try
            {
                if (formatComboBox.SelectedItem is TEX_FORMAT)
                {
                    SelectedTexSettings.Format = (TEX_FORMAT)formatComboBox.SelectedItem;
                    listViewCustom1.SelectedItems[0].SubItems[1].Text = SelectedTexSettings.Format.ToString();
                }
                pictureBox1.Image = Switch_Toolbox.Library.Imaging.GetLoadingImage();

                Thread = new Thread((ThreadStart)(() =>
                {
                    SelectedTexSettings.Compress();

                    Bitmap bitmap = STGenericTexture.DecodeBlockGetBitmap(SelectedTexSettings.DataBlockOutput[0], SelectedTexSettings.
                                                                          TexWidth, SelectedTexSettings.TexHeight, SelectedTexSettings.Format);

                    pictureBox1.Image = bitmap;
                    pictureBox1.Invoke((MethodInvoker) delegate {
                        pictureBox1.Refresh();
                    });
                }));

                Thread.Start();
            }
            catch
            {
                throw new Exception("Failed to load image!");
            }


            //  WidthLabel.Text = $"Width {pictureBox1.Image.Width}";
            //      HeightLabel.Text = $"Height {pictureBox1.Image.Height}";
        }