Exemplo n.º 1
0
        private void btnGaussSmooth_Click(object sender, EventArgs e)
        {
            if (!checkBox1.Checked && !checkBox2.Checked)
            {
                Stopwatch sw1 = Stopwatch.StartNew();
                ImageMatrix = ImageOperations.encrypt_image(ImageMatrix, text_seed.Text, Convert.ToInt32(text_tap.Text));
                sw1.Stop();
                MessageBox.Show("Encryption time :" + ((double)sw1.ElapsedMilliseconds / 1000).ToString() + " Seconds");
                Stopwatch sw = Stopwatch.StartNew();
                ImageOperations.Compress_image(ImageMatrix, text_seed.Text, Convert.ToInt32(text_tap.Text));
                sw.Stop();
                ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
                MessageBox.Show("Compression time: " + ((double)sw.ElapsedMilliseconds / 1000).ToString() + " Seconds");
                MessageBox.Show("Image has been encrypted and compressed successfully !", "Successful Operation");
            }
            else if (!checkBox2.Checked)
            {
                string x = "";
                for (int i = 0; i < Convert.ToInt32(textBox_size.Text); i++)
                {
                    x += "0";
                }
                Stopwatch sw = Stopwatch.StartNew();;

                d = ImageOperations.Hack(ImageMatrix, x, Convert.ToInt32(textBox_size.Text));
                sw.Stop();


                ImageOperations.DisplayImage(d[index].Key, pictureBox2);
                text_seed.Text   = d[index].Value.Key;
                text_tap.Text    = d[index].Value.Value.ToString();
                text_result.Text = d.Count.ToString();
                button2.Enabled  = true;
                button3.Enabled  = true;
                MessageBox.Show("Hack time :" + ((double)sw.ElapsedMilliseconds / 1000).ToString() + " Seconds");
            }
            else
            {
                Stopwatch sw = Stopwatch.StartNew();
                ImageMatrix = ImageOperations.encrypt_image(ImageMatrix, seed, tap);
                ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
                sw.Stop();
                MessageBox.Show("Decryption time :" + ((double)sw.ElapsedMilliseconds / 1000).ToString() + " Seconds");
            }
        }