Esempio n. 1
0
 public PurifyOptions_form(DdsFile dds, Purify_options options)
 {
     InitializeComponent();
     updateChannels = new bool[] { options.Red, options.Green, options.Blue, options.Alpha };
     PurifyAmount_trackBar.Value  = options.Contrast;
     PurifyRed_checkBox.Checked   = options.Red;
     PurifyGreen_checkBox.Checked = options.Green;
     PurifyBlue_checkBox.Checked  = options.Blue;
     PurifyAlpha_checkBox.Checked = options.Alpha;
     Preview_checkBox.Checked     = options.Preview;
     originalDDS = new DdsFile();
     originalDDS.CreateImage(dds.Resize(new Size(350, 350)), false);
     contrastTrackbarValue = options.Contrast;
     brightTrackbarValue   = options.Brightness;
     UpdatePreview();
 }
Esempio n. 2
0
        private void btnOpenMask_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName    = "*.dds";
            openFileDialog1.FilterIndex = 0;
            string caption = openFileDialog1.Title;

            try
            {
                openFileDialog1.Title = "Select DDS Image to use as a mask";
                DialogResult dr = openFileDialog1.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
            }
            finally { openFileDialog1.Title = caption; }

            using (FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read))
            {
                using (DdsFile ddsfile = new DdsFile())
                {
                    ddsfile.Load(fs, false); fs.Position = 0;

                    DdsFile ddsfile2 = ddsfile.Resize(ddsMaskCh1.Size);
                    ddsMaskCh1.DDSLoad(ddsfile2);
                    ddsMaskCh2.DDSLoad(ddsfile2);
                    ddsMaskCh3.DDSLoad(ddsfile2);
                    ddsMaskCh4.DDSLoad(ddsfile2);
                }

                ddsPanel1.LoadMask(fs);

                lbMaskW.Text        = ddsPanel1.MaskSize.Width + "";
                lbMaskH.Text        = ddsPanel1.MaskSize.Height + "";
                tlpMaskSize.Visible = true;

                fs.Close();
            }
        }
Esempio n. 3
0
        internal void Update_DDSdisplay()
        {
            if (dds == null)
            {
                return;
            }
            Wait_label.Visible = true;
            Wait_label.Refresh();
            DdsFile preview = new DdsFile();

            preview.CreateImage(dds, false);
            preview.SetPixels(TatPreview);
            if (!preview.Size.Equals(new System.Drawing.Size(512, 512)))
            {
                preview = preview.Resize(new System.Drawing.Size(512, 512));
            }
            Preview_pictureBox.Image = preview.Image;
            preview.Dispose();
            Wait_label.Visible      = false;
            Preset1_button.Font     = (currentPreset == 0) ? new Font(Preset1_button.Font, FontStyle.Bold) : new Font(Preset1_button.Font, FontStyle.Regular);
            Preset2_button.Font     = (currentPreset == 1) ? new Font(Preset2_button.Font, FontStyle.Bold) : new Font(Preset2_button.Font, FontStyle.Regular);
            Preset3_button.Font     = (currentPreset == 2) ? new Font(Preset3_button.Font, FontStyle.Bold) : new Font(Preset3_button.Font, FontStyle.Regular);
            Resize_checkBox.Checked = !dds.Size.Equals(new System.Drawing.Size(512, 512));
        }
Esempio n. 4
0
        private void TransformGo_button_Click(object sender, EventArgs e)
        {
            Wait_label.Visible = true;
            Wait_label.Refresh();

            dds.SetPixels(TatTransform);
            if (Black2Red_radioButton.Checked)
            {
                ChannelG_checkBox.Checked = false;
                ChannelB_checkBox.Checked = false;
                ChannelA_checkBox.Checked = false;
            }
            if (Black2Alpha_radioButton.Checked)
            {
                for (int i = 0; i < 3; i++)
                {
                    presets[i].aChannelHue = 0x00000000;
                    Presets_dataGridView.Rows[i].Cells["ChannelA"].Style.BackColor = presets[i].aChannelColor.SystemColor;
                }
            }
            else if (White2Alpha_radioButton.Checked)
            {
                for (int i = 0; i < 3; i++)
                {
                    presets[i].aChannelHue = 0x00FFFFFF;
                    Presets_dataGridView.Rows[i].Cells["ChannelA"].Style.BackColor = presets[i].aChannelColor.SystemColor;
                }
            }

            if (Resize_checkBox.Checked & !dds.Size.Equals(new Size(512, 512)))
            {
                Bitmap bits   = dds.GetImage(true, true, true, true, false);
                int    width  = bits.Width;
                int    height = bits.Height;

                float factorH = height / 512f;
                if (width == height)
                {
                    dds = dds.Resize(new Size(512, 512));
                }
                else if (width > height)
                {
                    float factor = 512f / width;
                    resizeSize = new Size(512, (int)(height * factor));
                    DdsFile tmp = new DdsFile();
                    tmp.CreateImage(dds, resizeSize.Width, resizeSize.Height, false);
                    resizePixels = tmp.GetImage(true, true, true, true, false).ToARGBData();
                    dds          = dds.Resize(new Size(512, 512));
                    dds.SetPixels(Resizer);
                }
                else if (width < height)
                {
                    float factor = 512f / height;
                    resizeSize = new Size((int)(width * factor), 512);
                    DdsFile tmp = new DdsFile();
                    tmp.CreateImage(dds, resizeSize.Width, resizeSize.Height, false);
                    resizePixels = tmp.GetImage(true, true, true, true, false).ToARGBData();
                    dds          = dds.Resize(new Size(512, 512));
                    dds.SetPixels(Resizer);
                }
            }

            Update_DDSdisplay();
        }