예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            double lamda1 = double.Parse(textBox1.Text);
            double lamda2 = double.Parse(textBox2.Text);
            double lamda3 = double.Parse(textBox3.Text);
            double Gamma  = double.Parse(textBox4.Text);
            double M      = double.Parse(textBox5.Text);
            double Xzero  = double.Parse(textBox6.Text);
            double Yzero  = double.Parse(textBox7.Text);
            double Zzero  = double.Parse(textBox8.Text);

            steg = new steganograph(lamda1, lamda2, lamda3, Xzero, Yzero, Zzero, Gamma, M, image.Height, image.Width);

            StreamReader rw   = new StreamReader(filename);
            string       read = rw.ReadToEnd();

            char[] ins   = read.ToCharArray();
            char[] input = new char[ins.Length + 3];
            for (int ii = 0; ii < ins.Length; ii++)
            {
                input[ii] = ins[ii];
            }
            input[ins.Length]     = (char)21;
            input[ins.Length + 1] = (char)21;
            input[ins.Length + 2] = (char)21;
            int[] a = new int[input.Length];
            for (int ii = 0; ii < input.Length; ii++)
            {
                a[ii] = (int)input[ii];
            }
            int[] binary_data   = steg.binary_maker(a);
            int   count         = 0;
            color combine_color = convertor();

            int[,] altered_red   = steg.stegno(combine_color.red, binary_data, ref count);
            int[,] altered_green = (int[, ])combine_color.green.Clone();
            int[,] altered_blue  = (int[, ])combine_color.blue.Clone();
            if (binary_data.Length > (image.Width * image.Height))
            {
                altered_green = steg.stegno(combine_color.green, binary_data, ref count);
            }
            if (binary_data.Length > 2 * (image.Width * image.Height))
            {
                altered_blue = steg.stegno(combine_color.blue, binary_data, ref count);
            }
            if (binary_data.Length > 3 * (image.Width * image.Height))
            {
                altered_red = steg.stegno_layer2(altered_red, binary_data, ref count);
            }
            if (binary_data.Length > 4 * (image.Width * image.Height))
            {
                altered_green = steg.stegno_layer2(altered_green, binary_data, ref count);
            }
            if (binary_data.Length > 5 * (image.Width * image.Height))
            {
                altered_blue = steg.stegno_layer2(altered_blue, binary_data, ref count);
            }
            if (binary_data.Length > 6 * (image.Width * image.Height))
            {
                altered_red = steg.stegno_layer3(altered_red, binary_data, ref count);
            }
            if (binary_data.Length > 7 * (image.Width * image.Height))
            {
                altered_green = steg.stegno_layer3(altered_green, binary_data, ref count);
            }
            if (binary_data.Length > 8 * (image.Width * image.Height))
            {
                altered_blue = steg.stegno_layer3(altered_blue, binary_data, ref count);
            }
            Bitmap image_save = new Bitmap(image.Width, image.Height);

            for (int ii = 0; ii < image.Width; ii++)
            {
                for (int jj = 0; jj < image.Height; jj++)
                {
                    Color temp = Color.FromArgb(altered_red[ii, jj], altered_green[ii, jj], altered_blue[ii, jj]);
                    image_save.SetPixel(ii, jj, temp);
                }
            }
            SaveFileDialog save = new SaveFileDialog();

            save.Filter = "Tif File(*.tif)|*.tif|Bitmap file(*.bmp)|*.bmp|Jpeg File(*.jpg)|*.jpg|PNG File(*.png)|*.png";
            DialogResult dr = save.ShowDialog();

            pictureBox1.Image = image_save;
            if (dr.Equals(DialogResult.OK))
            {
                filesave1 = save.FileName;
            }
            image_save.Save(filesave1);
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "proposed method")
     {
         double lamda1 = double.Parse(textBox1.Text);
         double lamda2 = double.Parse(textBox2.Text);
         double lamda3 = double.Parse(textBox3.Text);
         double Gamma  = double.Parse(textBox4.Text);
         double M      = double.Parse(textBox5.Text);
         double Xzero  = double.Parse(textBox6.Text);
         double Yzero  = double.Parse(textBox7.Text);
         double Zzero  = double.Parse(textBox8.Text);
         steg = new steganograph(lamda1, lamda2, lamda3, Xzero, Yzero, Zzero, Gamma, M, coverheight, coverwidth);
         //int[] input = new int[3 * secwidth * secheight + 2];
         int[] input    = new int[secwidth * secheight + 2];
         int   ind      = 2;
         int   capacity = coverheight * coverwidth / 8;
         input[0] = secheight;
         input[1] = secwidth;
         for (int ii = 0; ii < secwidth; ii++)
         {
             for (int jj = 0; jj < secheight; jj++)
             {
                 input[ind++] = Convert.ToInt32(pixel2[ii, jj].R);
             }
         }
         int before = ind;
         //for (int ii = 0; ii < secwidth; ii++)
         //    for (int jj = 0; jj < secheight; jj++)
         //        input[ind++] = Convert.ToInt32(pixel2[ii, jj].G);
         //for (int ii = 0; ii < secwidth; ii++)
         //    for (int jj = 0; jj < secheight; jj++)
         //        input[ind++] = Convert.ToInt32(pixel2[ii, jj].B);
         //steg.save_pixels(input, 2, "im.txt", input.Length);
         int[] binary_data = steg.binary_maker(input);
         int   count       = 0;
         if (binary_data.Length > 9 * (coverwidth * coverheight))
         {
             throw new Exception("سايز عكس ورودي بزرگ است!");
         }
         else
         {
             color combine_color = convertor(pixel);
             int[,] altered_red   = steg.stegno(combine_color.red, binary_data, ref count, 1);
             int[,] altered_green = (int[, ])combine_color.green.Clone();
             int[,] altered_blue  = (int[, ])combine_color.blue.Clone();
             if (binary_data.Length > (coverwidth * coverheight))
             {
                 altered_green = steg.stegno(combine_color.green, binary_data, ref count, 1);
             }
             if (binary_data.Length > 2 * (coverwidth * coverheight))
             {
                 altered_blue = steg.stegno(combine_color.blue, binary_data, ref count, 1);
             }
             if (binary_data.Length > 3 * (coverwidth * coverheight))
             {
                 altered_red = steg.stegno(altered_red, binary_data, ref count, 2);
             }
             if (binary_data.Length > 4 * (coverwidth * coverheight))
             {
                 altered_green = steg.stegno(altered_green, binary_data, ref count, 2);
             }
             if (binary_data.Length > 5 * (coverwidth * coverheight))
             {
                 altered_blue = steg.stegno(altered_blue, binary_data, ref count, 2);
             }
             if (binary_data.Length > 6 * (coverwidth * coverheight))
             {
                 altered_red = steg.stegno(altered_red, binary_data, ref count, 4);
             }
             if (binary_data.Length > 7 * (coverwidth * coverheight))
             {
                 altered_green = steg.stegno(altered_green, binary_data, ref count, 4);
             }
             if (binary_data.Length > 8 * (coverwidth * coverheight))
             {
                 altered_blue = steg.stegno(altered_blue, binary_data, ref count, 4);
             }
             Bitmap image_save = new Bitmap(coverwidth, coverheight, PixelFormat.Format24bppRgb);
             for (int ii = 0; ii < coverwidth; ii++)
             {
                 for (int jj = 0; jj < coverheight; jj++)
                 {
                     Color temp = Color.FromArgb(altered_red[ii, jj], altered_green[ii, jj], altered_blue[ii, jj]);
                     image_save.SetPixel(ii, jj, temp);
                 }
             }
             SaveFileDialog save = new SaveFileDialog();
             save.Filter = "Bitmap file(*.bmp)|*.bmp|Jpeg File(*.jpg)|*.jpg|PNG File(*.png)|*.png|TIFF File(*.tif)|*.tiff";
             DialogResult dr = save.ShowDialog();
             pictureBox1.Image = image_save;
             if (dr.Equals(DialogResult.OK))
             {
                 filesave1 = save.FileName;
             }
             ////ImageCodecInfo bmpCodec = FindEncoder(ImageFormat.Bmp);
             //EncoderParameters parameters = new EncoderParameters();
             //parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 24);
             image_save.Save(filesave1, ImageFormat.Bmp);
         }
     }
     else if (comboBox1.Text == "Yu method")
     {
     }
 }