Пример #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);
            color     combine_color = convertor();
            ArrayList images        = new ArrayList();

            steg.stegno2(combine_color.red, ref images);
            int height = Convert.ToInt32(images[0]);
            int width  = Convert.ToInt32(images[1]);

            images.RemoveAt(0); images.RemoveAt(0);
            steg.save_pixels(images, 0, "im1.txt");
            int sizeall = (3 * height * width);
            int before  = images.Count;

            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.green, ref images, 1, sizeall);
                steg.save_pixels(images, before, "im2.txt");
            }

            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.blue, ref images, 1, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.red, ref images, 2, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.green, ref images, 2, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.blue, ref images, 2, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.red, ref images, 4, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.green, ref images, 4, sizeall);
            }
            if (sizeall > images.Count)
            {
                steg.stegno(combine_color.blue, ref images, 4, sizeall);
            }
            Bitmap image_save = new Bitmap(width, height, PixelFormat.Format24bppRgb);
            int    count      = 0;

            for (int ii = 0; ii < width; ii++)
            {
                for (int jj = 0; jj < height; jj++)
                {
                    int r = Convert.ToInt32(images[count]);
                    int g = Convert.ToInt32(images[height * width + count]);
                    int b = Convert.ToInt32(images[2 * height * width + count]);
                    count++;
                    Color temp = Color.FromArgb(r, g, b);
                    image_save.SetPixel(ii, jj, temp);
                }
            }
            SaveFileDialog save = new SaveFileDialog();

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

            pictureBox2.Image = image_save;
            if (dr.Equals(DialogResult.OK))
            {
                filesave1 = save.FileName;
            }
            image_save.Save(filesave1, ImageFormat.Bmp);
        }
Пример #2
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);

            int[] binary_image = new int[1];
            steg = new steganograph(lamda1, lamda2, lamda3, Xzero, Yzero, Zzero, Gamma, M, image.Height, image.Width);
            color combine_color = convertor();
            int   height = -1; int width = -1;
            int   count = 0;

            steg.stegno2(combine_color.red, ref binary_image, ref height, ref width, ref count);
            //int sizeall=(3 * height * width);
            int sizeall = (3 * height * width);
            int before  = count;

            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.green, ref binary_image, 1, ref count);
            }

            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.blue, ref binary_image, 1, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.red, ref binary_image, 2, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.green, ref binary_image, 2, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.blue, ref binary_image, 2, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.red, ref binary_image, 4, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.green, ref binary_image, 4, ref count);
            }
            if (count < binary_image.Length)
            {
                steg.stegno(combine_color.blue, ref binary_image, 4, ref count);
            }
            ArrayList images = new ArrayList();

            int[] bits  = new int[8];
            int   index = 0;

            for (int ii = 0; ii < binary_image.Length; ii++)
            {
                bits[index++] = binary_image[ii];
                if (index == 8)
                {
                    images.Add(steg.Convert_Binary_to_Int(bits));
                    index = 0;
                }
            }
            //steg.save_pixels(images, 0, "im.txt");
            Bitmap image_save = new Bitmap(width, height, PixelFormat.Format24bppRgb);

            count = 0;
            for (int ii = 0; ii < width; ii++)
            {
                for (int jj = 0; jj < height; jj++)
                {
                    int r = Convert.ToInt32(images[count]);
                    //int g = Convert.ToInt32(images[height*width+count]);
                    //int b = Convert.ToInt32(images[2*height * width + count]);
                    count++;
                    Color temp = Color.FromArgb(r, r, r);
                    image_save.SetPixel(ii, jj, temp);
                }
            }
            SaveFileDialog save = new SaveFileDialog();

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

            pictureBox2.Image = image_save;
            if (dr.Equals(DialogResult.OK))
            {
                filesave1 = save.FileName;
            }
            image_save.Save(filesave1, ImageFormat.Bmp);
        }