private void button1_Click(object sender, EventArgs e)
        {
            stopWatch = new Stopwatch();


            ImageMatrix_Enc = ImageOperations.Process(ImageMatrix, initSeedTxt.Text, Convert.ToInt32(TapIndxUpDown.Value));

            stopWatch.Start();
            ImageOperations.DisplayImage(ImageMatrix_Enc, pictureBox1);
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            textBox1.Text = elapsedTime.ToString();
            stopWatch.Reset();

            Queues = new List <SimplePriorityQueue <Node, int> >();
            stopWatch.Start();
            Queues = ImageOperations.getHistogram(ImageMatrix_Enc);
            stopWatch.Stop();
            TimeSpan ts1 = stopWatch.Elapsed;

            string elapsedTime1 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                ts1.Hours, ts1.Minutes, ts1.Seconds,
                                                ts1.Milliseconds / 10);

            textBox2.Text = elapsedTime1.ToString();
            stopWatch.Reset();

            ImageOperations.BuildHuffmanTree(Queues);
        }
        private async void btnDecompress_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "TDAS Images. (.tdas) |*.tdas";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                BinaryFile file  = new BinaryFile();
                Stopwatch  watch = new Stopwatch();
                watch.Start();
                lblStatus.Text = "Decompressing Image...";
                await Task.Run(() => file.Read(openFileDialog1.FileName));

                watch.Stop();
                lblStatus.Text = "Decompression Completed.";
                string te = watch.Elapsed.ToString(@"m\:ss");
                lblTimeTaken.Visible = true;
                lblTimeTaken.Text    = te;
                ImageMatrix          = file.Image;
                ImageHeight          = file.ImageHeight;
                ImageWidth           = file.ImageWidth;
                InitialSeed          = file.InitialSeed;
                TapPosition          = file.TapPosition;
                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
                txtHeight.Text = file.ImageHeight.ToString();
                txtWidth.Text  = file.ImageWidth.ToString();
                string tmp = Convert.ToString(file.InitialSeed, 2);
                txtInitialSeed.Text = tmp.PadLeft(file.NumberOfBits, '0');
                txtTapPosition.Text = file.TapPosition.ToString();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog() == true)
            {
                string OpenedFilePath = openFileDialog1.FileName;
                FilePath.Text = OpenedFilePath;
                ImageMatrix   = ImageOperations.OpenImage(OpenedFilePath);
                ImageOperations.DisplayImage(ImageMatrix, ImageBox);
                WidthTextBox.Text  = ImageOperations.GetWidth(ImageMatrix).ToString();
                HeightTextBox.Text = ImageOperations.GetHeight(ImageMatrix).ToString();
                int x = int.Parse(WidthTextBox.Text), y = int.Parse(HeightTextBox.Text);

                SeamCarving.leaveIt = new bool[y, x];      // O(1)
                // O(y * x)
                for (int i = 0; i < y; i++)                // O(y)
                {
                    for (int j = 0; j < x; j++)            // O(x)
                    {
                        SeamCarving.leaveIt[i, j] = false; // O(1)
                    }
                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            int    Tap  = Int32.Parse(textBox2.Text);
            string Seed = textBox4.Text.ToString();

            Program.GetKey(Seed, Tap);
            ImageOperations.DisplayImage(Program.OriginalImage, pictureBox1);
        }
Exemple #5
0
 public Output()
 {
     InitializeComponent();
     //Huffman_Tree t = new Huffman_Tree();
     //Program.OriginalImage = Decompress.OUTPUT;
     //Program.ApplyEncryptionOrDecryption(Convert.ToString(Program.seed1, 2), Program.tap2);
     ImageOperations.DisplayImage(Decompress.OUTPUT, pictureBox1);
     textBox1.Text = Decompress.elapsedTime;
 }
 private void openBitmapToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1 = new OpenFileDialog();
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         //Open the browsed image and display it
         string OpenedFilePath = openFileDialog1.FileName;
         ImageMatrix = ImageOperations.OpenImage(OpenedFilePath);
         ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
     }
 }
Exemple #7
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (radioButton3.Checked == false && radioButton4.Checked == false)
            {
                MessageBox.Show("Please select a Decryption method.");
                return;
            }
            int    Tap  = Int32.Parse(textBox3.Text);
            string Seed = textBox1.Text;

            if (radioButton4.Checked == true)
            {
                Seed = Program.ConvertAlpha(Seed);
            }
            Program.ApplyEncryptionOrDecryption(Seed, Tap);
            ImageOperations.DisplayImage(Program.OriginalImage, pictureBox1);
            txtWidth.Text = Program.elapsedTime;
            textBox6.Clear();
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            newWidth  = int.Parse(WidthTextBox.Text);   // O(1)
            newHeight = int.Parse(HeightTextBox.Text);  // O(1)

            if (TypesComboBox.SelectedIndex == 0)
            {
                resizedImage = ImageOperations.NormalResize(ImageMatrix, newHeight, newWidth);
                ImageOperations.DisplayImage(resizedImage, ImageBox);
            }
            else if (TypesComboBox.SelectedIndex == 1)
            {
                BW.DoWork               += BW_DoWork;
                ProgressBar.Minimum      = 1;
                ProgressBar.Maximum      = 100;
                BW.ProgressChanged      += BW_ProgressChanged;
                BW.WorkerReportsProgress = true;
                BW.RunWorkerCompleted   += BW_RunWorkerCompleted;
                BW.RunWorkerAsync();
            }
        }
        private void BtnOpen_Click(object sender, EventArgs e)
        {
            redValue.Items.Clear();
            redPriority.Items.Clear();
            blueValue.Items.Clear();
            bluePriority.Items.Clear();
            greenValue.Items.Clear();
            greenPriority.Items.Clear();

            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Open the browsed image and display it
                string OpenedFilePath = openFileDialog1.FileName;
                ImageMatrix = ImageOperations.OpenImage(OpenedFilePath);
                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
            }
            txtWidth.Text  = ImageOperations.GetWidth(ImageMatrix).ToString();
            txtHeight.Text = ImageOperations.GetHeight(ImageMatrix).ToString();
        }
 private void loadFromTextFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1 = new OpenFileDialog();
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         FileStream   fs     = new FileStream(openFileDialog1.FileName, FileMode.Open);
         StreamReader sr     = new StreamReader(fs);
         int          Width  = Convert.ToInt32(sr.ReadLine());
         int          Height = Convert.ToInt32(sr.ReadLine());
         ImageMatrix = new RGBPixel[Height, Width];
         for (int i = 0; i < Height; i++)
         {
             for (int j = 0; j < Width; j++)
             {
                 ImageMatrix[i, j].red   = Convert.ToByte(sr.ReadLine());
                 ImageMatrix[i, j].green = Convert.ToByte(sr.ReadLine());
                 ImageMatrix[i, j].blue  = Convert.ToByte(sr.ReadLine());
             }
         }
         ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
     }
 }
        private async void btnOpenImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "Bitmap Images. (.bmp) |*.bmp";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Open the bImageHeighted image and display it
                string OpenedFilePath = openFileDialog1.FileName;
                lblStatus.Text     = "Opening Image...";
                this.ActiveControl = metroLabel1;
                await Task.Run(() => ImageMatrix = ImageOperations.OpenImage(OpenedFilePath));

                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
                lblStatus.Text       = "Image Loaded.";
                txtWidth.Text        = ImageOperations.GetWidth(ImageMatrix).ToString();
                txtHeight.Text       = ImageOperations.GetHeight(ImageMatrix).ToString();
                ImageWidth           = Convert.ToInt32(txtWidth.Text);
                ImageHeight          = Convert.ToInt32(txtHeight.Text);
                lblTimeTaken.Visible = false;
            }
            this.ActiveControl = metroLabel1;
        }
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            string         OpenedFilePath;
            int            indicator = 1;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //Open the browsed image and Write it to The File and display it
                OpenedFilePath = openFileDialog1.FileName;
                ImageMatrix    = ImageOperations.GetPixelsTo_TheFile(OpenedFilePath);
                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);

                try
                {
                    // Fill The Buffer Into The Assembly File
                    indicator = Image_Text_Steganography_._Assembly.Assembly_Executer_DLL.FillBuffer(OpenedFilePath);
                    if (indicator == 0)
                    {
                        MessageBox.Show("Buffer Filled Successfully");
                    }
                    else
                    {
                        MessageBox.Show("Buffer DID NOT Filled Successfully", "WRONG", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
            txtWidth.Text  = ImageMatrix.GetLength(0).ToString();
            txtHeight.Text = ImageMatrix.GetLength(1).ToString();


            // ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
        }
 private async void EncodeImage(long initialSeed, byte tap, byte numberOfBits, bool alpha)
 {
     if (!alpha)
     {
         Register  register   = new Register(initialSeed, tap, numberOfBits); // O(1)
         long      pixelsDone = 0;                                            // UI
         Stopwatch watch      = new Stopwatch();                              //UI
         lblTimeTaken.Visible = true;                                         //UI
         lblStatus.Text       = "Encoding Image...";
         watch.Start();                                                       //UI
         for (int i = 0; i < ImageHeight; i++)                                // O(N^2)
         {
             await Task.Run(() =>
             {
                 for (int j = 0; j < ImageWidth; j++)                    //O(N^2)
                 {
                     ImageMatrix[i, j].red   ^= (byte)register.StepK(8); // O(1)
                     ImageMatrix[i, j].green ^= (byte)register.StepK(8); //O(1)
                     ImageMatrix[i, j].blue  ^= (byte)register.StepK(8); //O(1)
                     pixelsDone++;                                       // UI
                 }
             }).
             ContinueWith((ant) =>
             {
                 //lblStatus.Text = "Encoding " + pixelsDone + " pixels / " + (ImageHeight * ImageWidth) + " pixels : " + ((long)(pixelsDone * 100) / (ImageHeight * ImageWidth))
                 string te         = watch.Elapsed.ToString(@"m\:ss");
                 lblTimeTaken.Text = "Time Elapsed : " + te;
             }
                          , TaskScheduler.FromCurrentSynchronizationContext());
         }
         watch.Stop();
         string tsOut = watch.Elapsed.ToString(@"m\:ss");
         lblTimeTaken.Text = "Time Elapsed : " + tsOut;
         lblStatus.Text    = "Image Encoded.";
         ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
     }
     else
     {
         PasswordRegister register   = new PasswordRegister(txtInitialSeed.Text, TapPosition); // O(1)
         long             pixelsDone = 0;                                                      // UI
         Stopwatch        watch      = new Stopwatch();                                        //UI
         lblTimeTaken.Visible = true;                                                          //UI
         lblStatus.Text       = "Encoding Image...";
         watch.Start();                                                                        //UI
         for (int i = 0; i < ImageHeight; i++)
         {
             await Task.Run(() =>
             {
                 for (int j = 0; j < ImageWidth; j++)
                 {
                     ImageMatrix[i, j].red   ^= (byte)register.StepK(8);
                     ImageMatrix[i, j].green ^= (byte)register.StepK(8);
                     ImageMatrix[i, j].blue  ^= (byte)register.StepK(8);
                     pixelsDone++; // UI
                 }
             }).
             ContinueWith((ant) =>
             {
                 //lblStatus.Text = "Encoding " + pixelsDone + " pixels / " + (ImageHeight * ImageWidth) + " pixels : " + ((long)(pixelsDone * 100) / (ImageHeight * ImageWidth))
                 string te         = watch.Elapsed.ToString(@"m\:ss");
                 lblTimeTaken.Text = "Time Elapsed : " + te;
             }
                          , TaskScheduler.FromCurrentSynchronizationContext());
         }
         watch.Stop();
         string tsOut = watch.Elapsed.ToString(@"m\:ss");
         lblTimeTaken.Text = "Time Elapsed : " + tsOut;
         lblStatus.Text    = "Image Encoded.";
         ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
     }
     //ImageColorFrequencies.GenerateFromImage(ImageMatrix);
 }
 private void BW_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     ProgressBar.Value = e.ProgressPercentage;
     ImageOperations.DisplayImage(SeamCarving.TempMatrix, ImageBox);
 }
 public OpForm()
 {
     InitializeComponent();
     ImageOperations.DisplayImage(Program.OriginalImage, pictureBox1);
 }
 private void BW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ImageOperations.DisplayImage(resizedImage, ImageBox);
 }
 private void mouseDown(object sender, MouseButtonEventArgs e)
 {
     mouseThread = new Thread(new ThreadStart(delegate() { getPixels(sender, e); }));
     ImageOperations.DisplayImage(ImageMatrix, ImageBox);
     mouseThread.Start();
 }