public check_end stegno(int[,] image)
        {
            check_end ch     = new check_end();
            ArrayList output = new ArrayList();

            restrict();
            int count = 0;

            int[]  bits          = new int[8];
            double Xnegative1    = xzero;
            double Ynegative1    = yzero;
            double Znegative1    = zzero;
            int    endnotation   = 1;
            int    last_notation = 1;
            int    index         = 0;
            double X             = (l1 * Xnegative1) - (Math.Pow(Xnegative1, 3)) - (gamma * Math.Pow(Math.Abs(Ynegative1), m) * Xnegative1);
            double Y             = (l2 * Ynegative1) - (Math.Pow(Ynegative1, 3)) - (gamma * Math.Pow(Math.Abs(Znegative1), m) * Ynegative1);
            double Z             = (l3 * Znegative1) - (Math.Pow(Znegative1, 3)) - (gamma * Math.Pow(Math.Abs(Xnegative1), m) * Znegative1);
            double select        = turning(Xnegative1, Ynegative1, Znegative1);

            for (int ii = 0; ii < domains.Length - 1; ii++)
            {
                if (domains[ii] <= select && domains[ii + 1] > select)
                {
                    index = ii;
                    break;
                }
            }
            Random rr = new Random(index);

            int[] rand_sq2 = sq_rand_gen(Width, rr);
            for (int kk = 0; kk < Height; kk++)
            {
                if (endnotation > 4)
                {
                    break;
                }
                index  = 0;
                X      = (l1 * Xnegative1) - (Math.Pow(Xnegative1, 3)) - (gamma * Math.Pow(Math.Abs(Ynegative1), m) * Xnegative1);
                Y      = (l2 * Ynegative1) - (Math.Pow(Ynegative1, 3)) - (gamma * Math.Pow(Math.Abs(Znegative1), m) * Ynegative1);
                Z      = (l3 * Znegative1) - (Math.Pow(Znegative1, 3)) - (gamma * Math.Pow(Math.Abs(Xnegative1), m) * Znegative1);
                select = turning(Xnegative1, Ynegative1, Znegative1);
                for (int ii = 0; ii < domains.Length - 1; ii++)
                {
                    if (domains[ii] <= select && domains[ii + 1] > select)
                    {
                        index = ii;
                        break;
                    }
                }
                rr = new Random(index);
                int[] rand_sq = sq_rand_gen(Width, rr);
                for (int ii = 0; ii < rand_sq.Length && endnotation < 4; ii++)
                {
                    int index2  = rand_sq[ii];
                    int context = image[index2, rand_sq2[kk]];
                    if (count == 8)
                    {
                        int temp = Convert_Binary_to_Int(bits);
                        if (temp == 21)
                        {
                            endnotation++;
                            if (temp == last_notation)
                            {
                                endnotation++;
                            }
                        }
                        else
                        {
                            output.Add(Convert.ToChar(temp));
                            endnotation = 1;
                        }
                        count         = 0;
                        last_notation = temp;
                    }
                    if (context % 2 == 0)
                    {
                        bits[count++] = 0;
                    }
                    else
                    {
                        bits[count++] = 1;
                    }
                }

                Xnegative1 = X; Ynegative1 = Y; Znegative1 = Z;
            }
            ch.checking = endnotation;
            if (((Width * Height) % 8) != 0 && endnotation < 4)
            {
                output.RemoveAt(output.Count - 1);
            }
            ch.output = (ArrayList)output.Clone();
            return(ch);
        }
        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();
            check_end data          = steg.stegno(combine_color.red);
            ArrayList fetch_data    = (ArrayList)data.output.Clone();
            string    output        = "";

            for (int ii = 0; ii < fetch_data.Count; ii++)
            {
                output += fetch_data[ii].ToString();
            }
            if (data.checking < 4)
            {
                data       = steg.stegno(combine_color.green);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno(combine_color.blue);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer2(combine_color.red);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer2(combine_color.green);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer2(combine_color.blue);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer3(combine_color.red);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer3(combine_color.green);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            if (data.checking < 4)
            {
                data       = steg.stegno_layer3(combine_color.blue);
                fetch_data = (ArrayList)data.output.Clone();
                for (int ii = 0; ii < fetch_data.Count; ii++)
                {
                    output += fetch_data[ii].ToString();
                }
            }
            SaveFileDialog sf = new SaveFileDialog();

            sf.Filter = "text files|*.txt";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                filesave1 = sf.FileName;
            }
            textBox11.Text = output;
            steg.save(filesave1, output);
        }