예제 #1
0
 /// <summary>
 /// Set the alpha channel of the current image from the given DDS file stream.
 /// </summary>
 /// <param name="image"><see cref="Stream"/> containing a DDS image.</param>
 public void SetAlphaFromGreyscale(Stream image)
 {
     DdsFile greyscale = new DdsFile();
     greyscale.Load(image, false);
     ddsFile.SetAlphaFromGreyscale(greyscale);
     ckb_CheckedChanged(null, null);
 }
예제 #2
0
        /// <summary>
        /// Apply the supplied images to the areas of the base image defined by the
        /// channels in the currently loaded mask.
        /// </summary>
        /// <param name="ch1Image">The <see cref="T:System.IO.Stream"/> containing the DDS image to apply to the image when the first channel of the mask is active.</param>
        /// <param name="ch2Image">The <see cref="T:System.IO.Stream"/> containing the DDS image to apply to the image when the second channel of the mask is active.</param>
        /// <param name="ch3Image">The <see cref="T:System.IO.Stream"/> containing the DDS image to apply to the image when the third channel of the mask is active.</param>
        /// <param name="ch4Image">The <see cref="T:System.IO.Stream"/> containing the DDS image to apply to the image when the fourth channel of the mask is active.</param>
        public void ApplyImage(Stream ch1Image, Stream ch2Image, Stream ch3Image, Stream ch4Image)
        {
            if (!this.loaded || !this.MaskLoaded) return;

            DdsFile ch1dds = null, ch2dds = null, ch3dds = null, ch4dds = null;
            try
            {
                this.Enabled = false;
                Application.UseWaitCursor = true;
                Application.DoEvents();
                if (ch1Image != null) { ch1dds = new DdsFile(); ch1dds.Load(ch1Image, false); }
                if (ch2Image != null) { ch2dds = new DdsFile(); ch2dds.Load(ch2Image, false); }
                if (ch3Image != null) { ch3dds = new DdsFile(); ch3dds.Load(ch3Image, false); }
                if (ch4Image != null) { ch4dds = new DdsFile(); ch4dds.Load(ch4Image, false); }
                ddsFile.MaskedApplyImage(this.ddsMask, ch1dds, ch2dds, ch3dds, ch4dds);
            }
            finally { this.Enabled = true; Application.UseWaitCursor = false; Application.DoEvents(); }
            this.ckb_CheckedChanged(null, null);
        }
예제 #3
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();
            }
        }