Esempio n. 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtDecodeImageLocation.Text.Length > 0)
                {
                    TP_File file = TP_Stenography.DecodeImage((Bitmap)Bitmap.FromFile(txtDecodeImageLocation.Text), txtDecodeKey.Text);
                    saveFileDialog2.FileName = file.GetFileName();

                    DialogResult d = saveFileDialog2.ShowDialog();
                    if (d == DialogResult.OK)
                    {
                        file.Save(saveFileDialog2.FileName);
                    }

                    MessageBox.Show("File Extracted!", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            {
                MessageBox.Show("There was an error extracting a file from this image.\nPossbile causes include:\n\n" +
                                " - Invalid decryption key\n - Image does not contain any hidden files\n - Image was corrupted", "2pix",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEncryptKeyAgain.Text != txtEncryptKey.Text)
                {
                    MessageBox.Show("The passwords do not match!", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (txtEncodeImage.Text.Length > 0 && txtEncodeFile.Text.Length > 0)
                {
                    DialogResult d = saveFileDialog1.ShowDialog();
                    if (d == DialogResult.OK)
                    {
                        // Format the image for encoding
                        Image originalImage = Bitmap.FromFile(txtEncodeImage.Text);

                        // See if we need to resize the image
                        Size scale;
                        if (cbScaleImage.Checked)
                        {
                            scale = GetImageScale();
                        }
                        else
                        {
                            scale = new Size(originalImage.Width, originalImage.Height);
                        }

                        // Get a bitmap of the correct size
                        Bitmap   image = new Bitmap(scale.Width, scale.Height);
                        Graphics g     = Graphics.FromImage(image);
                        g.DrawImage(originalImage, 0, 0, scale.Width, scale.Height);

                        // Encode and save
                        TP_Stenography.EncodeImage(image, new TP_File(txtEncodeFile.Text, txtEncryptKey.Text), ddlQuality.SelectedIndex + 1);
                        image.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
                    }

                    MessageBox.Show("File Saved!", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (FileTooLargeForImageException)
            {
                MessageBox.Show("The image is not large enough to hold that file.", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "2pix", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string fileName = textBox1.Text;
                string key      = textBox2.Text;

                string dest = fileName.Substring(0, fileName.LastIndexOf("\\")) + "\\";

                if (File.Exists(fileName))
                {
                    TP_File file = TP_Stenography.DecodeImage((Bitmap)Bitmap.FromFile(fileName), key);

                    // Get the original file name, but don't overwrite anything
                    string name = dest + file.GetFileName();
                    if (File.Exists(name))
                    {
                        name = dest + "2pix_" + file.GetFileName();
                    }

                    file.Save(name);
                }

                MessageBox.Show("The file was extracted!", "2pix",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Close();
            }
            catch
            {
                MessageBox.Show("There was an error extracting a file from this image.\nPossbile causes include:\n\n" +
                                " - Invalid decryption key\n - Image does not contain any hidden files\n - Image was corrupted", "2pix",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }
        }