Beispiel #1
0
        private void button13_Click(object sender, EventArgs e)
        {
            if (loadedFilePath == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;
                SimpleObjectFactory sof          = new SimpleObjectFactory();
                IImageInImage       ImageInImage = sof.getImageInImage();
                Bitmap s = ImageInImage.Extract(i2ie);

                string path = loadedFilePath.Remove(loadedFilePath.Length - fileNameSize) + justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.jpg";
                if (!File.Exists(path))
                {
                    s.Save(path);
                    label6.Text = path;
                }
                else if (File.Exists(path))
                {
                    MessageBox.Show(justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.jpg File already exist...!");
                    label6.Text = "";
                }
                s.Dispose();
                Cursor.Current = Cursors.Arrow;
                loadedFilePath = "";
            }
        }
Beispiel #2
0
        ///////////////////////////////////////////////TEXT IN DOC : EMBEDD : LOGIC ///////////////////////////////////////////////
        private void button2_Click(object sender, EventArgs e)
        {
            //Checking for validation.
            if (loadedFilePath == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
                textBox1.Text = "";
                textBox2.Text = "";
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("Your Msg Should not be blank.");
            }
            else if (textBox2.Text.Length > secretmsgsize)
            {
                MessageBox.Show("You can Embedd Maximum " + secretmsgsize + " characters.");
                textBox2.Text = "";
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;

                SimpleObjectFactory sof      = new SimpleObjectFactory();
                ITextFile           textFile = sof.getTextFile();
                string text = textFile.getTextFromFile(loadedFilePath);

                string msg = textBox2.Text;

                ITextInDoc textInDoc = sof.getTextInDoc();
                text = textInDoc.Embedd(text, msg);

                string path = loadedFilePath.Remove(loadedFilePath.Length - fileNameSize) + justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.txt";

                if (!File.Exists(path))
                {
                    File.Create(path).Dispose();
                    using (TextWriter tw = new StreamWriter(path))
                    {
                        tw.Write("" + text + "");
                        tw.Close();
                    }
                    label33.Text = "Output File : " + path;
                }
                else if (File.Exists(path))
                {
                    using (TextWriter tw = new StreamWriter(path))
                    {
                        MessageBox.Show(justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.txt File already exist...!");
                        label33.Text = "";
                    }
                }

                Cursor.Current = Cursors.Arrow;
                textBox1.Text  = "";
                textBox2.Text  = "";
                msg            = "";
                loadedFilePath = "";
            }
        }
Beispiel #3
0
        ////////////////////////////////////////////TEXT IN IMAGE : EXTRACT : LOGIC ///////////////////////////////////////////////

        private void button11_Click(object sender, EventArgs e)
        {
            if (loadedFilePath == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;

                SimpleObjectFactory sof         = new SimpleObjectFactory();
                ITextInImage        textInImage = sof.getTextInImage();
                msg            = textInImage.Extract(loadedFilePath);
                textBox10.Text = msg;
                loadedFilePath = "";
                Cursor.Current = Cursors.Arrow;
            }
        }
Beispiel #4
0
        ////////////////////////////////////////////TEXT IN IMAGE : EMBEDD : LOGIC ///////////////////////////////////////////////

        private void button9_Click(object sender, EventArgs e)
        {
            if (loadedFilePath == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
                textBox6.Text = "";
                textBox7.Text = "";
            }
            else if (textBox7.Text == "")
            {
                MessageBox.Show("Your Msg Should not be blank.");
            }
            else if (textBox7.Text.Length > secretmsgsize)
            {
                MessageBox.Show("You can Embedd Maximum " + secretmsgsize + " characters.");
                textBox7.Text = "";
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;

                SimpleObjectFactory sof = new SimpleObjectFactory();
                //Text Processing
                string msg = textBox7.Text;

                ITextInImage textInImage = sof.getTextInImage();
                Bitmap       eMap        = textInImage.Embedd(loadedFilePath, msg);

                string path = loadedFilePath.Remove(loadedFilePath.Length - fileNameSize) + justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.jpg";
                if (!File.Exists(path))
                {
                    eMap.Save(path);
                    label31.Text = "Output File : " + path;
                }
                else if (File.Exists(path))
                {
                    MessageBox.Show(justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.jpg File already exist...!");
                    label31.Text = "";
                }

                loadedFilePath = "";
                Cursor.Current = Cursors.Arrow;
            }
        }
Beispiel #5
0
        ////////////////////////////////////////////TEXT IN DOC : EXTRACT : LOGIC ///////////////////////////////////////////////
        private void button4_Click(object sender, EventArgs e)
        {
            if (loadedFilePath == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;
                SimpleObjectFactory sof      = new SimpleObjectFactory();
                ITextFile           textFile = sof.getTextFile();
                string text = textFile.getTextFromFile(loadedFilePath);

                ITextInDoc textInDoc = sof.getTextInDoc();
                text = textInDoc.Extract(text);

                textBox11.Text = text;
                loadedFilePath = "";
                Cursor.Current = Cursors.Arrow;
            }
        }
Beispiel #6
0
        ////////////////////////////////////////////IMAGE IN IMAGE : EMBEDD : LOGIC ///////////////////////////////////////////////

        private void button7_Click(object sender, EventArgs e)
        {
            //Checking for validation.
            if (textBox4.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("File Path cannot be blank...!");
            }
            else if (i2isize > secretmsgsize)
            {
                MessageBox.Show("You can Embedd Maximum " + secretmsgsize + " Pixels.");
                textBox5.Text = "";
            }
            else
            {
                Cursor.Current = Cursors.WaitCursor;

                SimpleObjectFactory sof          = new SimpleObjectFactory();
                IImageInImage       ImageInImage = sof.getImageInImage();
                Bitmap eMap = ImageInImage.Embedd(i2ic, i2is);

                string path = i2is.Remove(i2is.Length - justFName(i2is).Length) + justFName(i2is).Remove(justFName(i2is).Length - 4) + "1.jpg";

                if (!File.Exists(path))
                {
                    eMap.Save(path);
                    label20.Text = "Output File : " + path;
                }
                else if (File.Exists(path))
                {
                    MessageBox.Show(justFName(loadedFilePath).Remove(fileNameSize - 4) + "1.jpg File already exist...!");
                    label20.Text = "";
                }

                eMap.Dispose();
                Cursor.Current = Cursors.Arrow;
                loadedFilePath = "";
            }
        }
Beispiel #7
0
        public new Bitmap Extract(String sPath)
        {
            SimpleObjectFactory sof = new SimpleObjectFactory();

            IImageFile cimg    = sof.getImageFile();
            Bitmap     cbmp    = cimg.getBitMap(sPath);
            int        cwidth  = cimg.getWidth(sPath);
            int        cheight = cimg.getHeight(sPath);

            int    cx = 0, cy = 0;
            string swidth = null, sheight = null;

            for (int i = 0; i < 5; i++)
            {
                Color lp = cbmp.GetPixel(cx, cy);
                int   ca = lp.A;
                int   cr = lp.R;
                int   cg = lp.G;
                int   cb = lp.B;
                swidth += (cr % 2).ToString();
                swidth += (cg % 2).ToString();
                swidth += (cb % 2).ToString();
                cx++;
            }


            for (int i = 0; i < 5; i++)
            {
                Color lp = cbmp.GetPixel(cx, cy);
                int   ca = lp.A;
                int   cr = lp.R;
                int   cg = lp.G;
                int   cb = lp.B;
                sheight += (cr % 2).ToString();
                sheight += (cg % 2).ToString();
                sheight += (cb % 2).ToString();
                cx++;
            }


            int sw = Convert.ToInt32(swidth, 2);
            int sh = Convert.ToInt32(sheight, 2);

            Bitmap s = new Bitmap(sw, sh);

            for (int i = 0; i < sh; i++)
            {
                for (int j = 0; j < sw; j++)
                {
                    string all = null;
                    for (int k = 0; k < 11; k++)
                    {
                        Color lp = cbmp.GetPixel(cx, cy);
                        int   ca = lp.A;
                        int   cr = lp.R;
                        int   cg = lp.G;
                        int   cb = lp.B;

                        all += (cr % 2).ToString();
                        all += (cg % 2).ToString();
                        all += (cb % 2).ToString();

                        cx++;
                        if (cx == cwidth)
                        {
                            cx = 0; cy++;
                        }
                    }
                    string alpha = all.Substring(0, 8);
                    int    sa    = Convert.ToInt32(alpha, 2);
                    string red   = all.Substring(8, 8);
                    int    sr    = Convert.ToInt32(red, 2);
                    string green = all.Substring(16, 8);
                    int    sg    = Convert.ToInt32(green, 2);
                    string blue  = all.Substring(24, 8);
                    int    sb    = Convert.ToInt32(blue, 2);

                    s.SetPixel(j, i, Color.FromArgb(sa, sr, sg, sb));
                }
            }

            return(s);
        }
Beispiel #8
0
        public Bitmap Embedd(String cPath, String sPath)
        {
            SimpleObjectFactory sof = new SimpleObjectFactory();

            IImageFile imgs    = sof.getImageFile();
            Bitmap     bmps    = imgs.getBitMap(sPath);
            int        widths  = imgs.getWidth(sPath);
            int        heights = imgs.getHeight(sPath);

            IImageFile imgc    = sof.getImageFile();
            Bitmap     bmpc    = imgs.getBitMap(cPath);
            int        widthc  = imgs.getWidth(cPath);
            int        heightc = imgs.getHeight(cPath);

            Bitmap eMap = imgc.getBitMap(cPath);

            int cx = 0, cy = 0;

            long   len  = widths;
            string blen = Convert.ToString(len, 2);

            while (blen.Length != 15)
            {
                blen = "0" + blen;
            }

            len = heights;
            string stemp = Convert.ToString(len, 2);

            while (stemp.Length != 15)
            {
                stemp = "0" + stemp;
            }

            blen = blen + stemp;

            for (int r = 0; r < 10; r++)
            {
                Color lp = eMap.GetPixel(cx, cy);
                int   ca = lp.A;
                int   cr = lp.R;
                int   cg = lp.G;
                int   cb = lp.B;

                if (int.Parse(blen[3 * r].ToString()) != cr % 2)
                {
                    if (blen[3 * r] == '0')
                    {
                        cr--;
                    }
                    else
                    {
                        cr++;
                    }
                }
                if (int.Parse(blen[(3 * r) + 1].ToString()) != cg % 2)
                {
                    if (blen[(3 * r) + 1] == '0')
                    {
                        cg--;
                    }
                    else
                    {
                        cg++;
                    }
                }
                if (int.Parse(blen[(3 * r) + 2].ToString()) != cb % 2)
                {
                    if (blen[(3 * r) + 2] == '0')
                    {
                        cb--;
                    }
                    else
                    {
                        cb++;
                    }
                }
                eMap.SetPixel(cx, cy, Color.FromArgb(ca, cr, cg, cb));
                cx++;
            }


            for (int y = 0; y < heights; y++)
            {
                for (int x = 0; x < widths; x++)
                {
                    Color p = bmps.GetPixel(x, y);

                    int a = p.A;
                    int r = p.R;
                    int g = p.G;
                    int b = p.B;

                    string temp = null;
                    string sa   = Convert.ToString(a, 2);
                    while (sa.Length != 8)
                    {
                        sa = "0" + sa;
                    }
                    string sr = Convert.ToString(r, 2);
                    while (sr.Length != 8)
                    {
                        sr = "0" + sr;
                    }
                    string sg = Convert.ToString(g, 2);
                    while (sg.Length != 8)
                    {
                        sg = "0" + sg;
                    }
                    string sb = Convert.ToString(b, 2);
                    while (sb.Length != 8)
                    {
                        sb = "0" + sb;
                    }
                    //int cflag = 0;
                    temp = sa + sr + sg + sb + "0";
                    for (int m = 0; m < 11; m++)
                    {
                        Color cp = eMap.GetPixel(cx, cy);
                        int   ca = cp.A;
                        int   cr = cp.R;
                        int   cg = cp.G;
                        int   cb = cp.B;

                        if (int.Parse(temp[3 * m].ToString()) != cr % 2)
                        {
                            if (temp[3 * m] == '0')
                            {
                                cr--;
                            }
                            else
                            {
                                cr++;
                            }
                        }
                        if (int.Parse(temp[(3 * m) + 1].ToString()) != cg % 2)
                        {
                            if (temp[(3 * m) + 1] == '0')
                            {
                                cg--;
                            }
                            else
                            {
                                cg++;
                            }
                        }
                        if (int.Parse(temp[(3 * m) + 2].ToString()) != cb % 2)
                        {
                            if (temp[(3 * m) + 2] == '0')
                            {
                                cb--;
                            }
                            else
                            {
                                cb++;
                            }
                        }
                        eMap.SetPixel(cx, cy, Color.FromArgb(ca, cr, cg, cb));
                        cx++;
                        if (cx == widthc)
                        {
                            cx = 0; cy++;
                        }
                    }
                }
            }

            return(eMap);
        }
Beispiel #9
0
        public Bitmap Embedd(string path, string msg)
        {
            String binMsg = "";

            for (int i = 0; i < msg.Length; i++)
            {
                binMsg += Convert.ToString(msg[i], 2).PadLeft(8, '0');
            }
            binMsg += "11111111";

            SimpleObjectFactory sof       = new SimpleObjectFactory();
            IImageFile          ImageFile = sof.getImageFile();
            Bitmap bmp      = ImageFile.getBitMap(path);
            int    width    = ImageFile.getWidth(path);
            int    height   = ImageFile.getHeight(path);
            int    binIndex = 0;
            int    flag     = 0;

            IImageFile sImage = sof.getImageFile();
            Bitmap     eMap   = sImage.getBitMap(path);

            for (int y = 0; y < height && flag == 0; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color p = bmp.GetPixel(x, y);

                    int a = p.A;
                    int r = p.R;
                    int g = p.G;
                    int b = p.B;

                    if (int.Parse(binMsg[binIndex].ToString()) != r % 2)
                    {
                        if (binMsg[binIndex] == '0')
                        {
                            r--;
                        }
                        else
                        {
                            r++;
                        }
                    }
                    eMap.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                    binIndex++;
                    if (binIndex == binMsg.Length)
                    {
                        flag = 1; break;
                    }
                    if (int.Parse(binMsg[binIndex].ToString()) != g % 2)
                    {
                        if (binMsg[binIndex] == '0')
                        {
                            g--;
                        }
                        else
                        {
                            g++;
                        }
                    }
                    eMap.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                    binIndex++;
                    if (binIndex == binMsg.Length)
                    {
                        flag = 1; break;
                    }
                    if (int.Parse(binMsg[binIndex].ToString()) != b % 2)
                    {
                        if (binMsg[binIndex] == '0')
                        {
                            b--;
                        }
                        else
                        {
                            b++;
                        }
                    }
                    eMap.SetPixel(x, y, Color.FromArgb(a, r, g, b));
                    binIndex++;
                    if (binIndex == binMsg.Length)
                    {
                        flag = 1; break;
                    }
                }
            }


            return(eMap);
        }
Beispiel #10
0
        public string Extract(string path)
        {
            SimpleObjectFactory sof       = new SimpleObjectFactory();
            IImageFile          ImageFile = sof.getImageFile();
            Bitmap bmp = ImageFile.getBitMap(path);
            int    width = bmp.Width;
            int    height = bmp.Height;
            int    flag = 0;
            String msg = "", binMsg = "";

            //IImageFile sImage = sof.getImageFile();
            //Bitmap eMap = sImage.getBitMap(path);

            for (int y = 0; y < height && flag == 0; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Color p = bmp.GetPixel(x, y);

                    int a = p.A;
                    int r = p.R;
                    int g = p.G;
                    int b = p.B;

                    binMsg += (r % 2).ToString();
                    if (binMsg.Length > 8)
                    {
                        if (binMsg.Substring(binMsg.Length - 8, 8).Equals("11111111") && binMsg.Length % 8 == 0)
                        {
                            flag = 1; break;
                        }
                    }

                    binMsg += (g % 2).ToString();
                    if (binMsg.Length > 8)
                    {
                        if (binMsg.Substring(binMsg.Length - 8, 8).Equals("11111111") && binMsg.Length % 8 == 0)
                        {
                            flag = 1; break;
                        }
                    }

                    binMsg += (b % 2).ToString();
                    if (binMsg.Length > 8)
                    {
                        if (binMsg.Substring(binMsg.Length - 8, 8).Equals("11111111") && binMsg.Length % 8 == 0)
                        {
                            flag = 1; break;
                        }
                    }
                }
            }


            if (binMsg.Substring(binMsg.Length - 8, 8).Equals("11111111") && binMsg.Length % 8 == 0)
            {
                binMsg = binMsg.Remove(binMsg.Length - 8);

                for (int i = 0; i < binMsg.Length; i += 8)
                {
                    msg += (char)(128 * int.Parse(binMsg[i].ToString()) + 64 * int.Parse(binMsg[i + 1].ToString()) + 32 * int.Parse(binMsg[i + 2].ToString()) + 16 * int.Parse(binMsg[i + 3].ToString()) + 8 * int.Parse(binMsg[i + 4].ToString()) + 4 * int.Parse(binMsg[i + 5].ToString()) + 2 * int.Parse(binMsg[i + 6].ToString()) + int.Parse(binMsg[i + 7].ToString()));
                }
            }
            else
            {
                msg = "";
                MessageBox.Show("No Message Found.");
            }

            return(msg);
        }