Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > .NET Framework 3.5
|
.NET Framework 3.5 For discussion of the Microsoft .NET Framework 3.5.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 3.5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2009, 08:31 AM
Registered User
 
Join Date: Jul 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Image processing/Steganography in C#

hello all,
I am working on a project in steganography for my final year.This project is based on hiding text data in image file.
I am using Least Significant Bit algorithm to start with.

I am starting by converting text file as well as image file to byte array and then to bit array.I have been successful
in converting text to bit array.

but problem is with image file. when i convert it to bits , the program just hangs and does not respond(may be because of size
of the image )

I hav pasted the code for both text file as well as image file below.I hav made the image conversion working by
running loop until 512,but i want to read the whole image into bit array.

How can I achieve this? Can there be a better method to do steganography? Should I use multithreading..Please help.

Any advice for code improvement is welcomed.
Thanks in advance.

Code:
private void browsetext_Click(object sender, EventArgs e)
        {
            try
            {
                string name = null;
                string text=null;
                
                FileStream fs;
                StreamReader sr;
                OpenFileDialog op1 = new OpenFileDialog();
                op1.Filter = "text files(*.txt,*.doc,*.docx)|*.txt;*.doc;*.docx";
                if (op1.ShowDialog() == DialogResult.OK)
                {
                    name = op1.FileName;
                    fs = new FileStream(@name, FileMode.Open, FileAccess.Read);
                    sr = new StreamReader(fs);
                    text= sr.ReadToEnd();
                    textBox1.Text = text;
                    byte[] b = Encoding.ASCII.GetBytes(text);
                    for(int i=0;i<b.Length;i++)
                    {
                    textBox2.Text+=b[i].ToString()+" ";
                    }
                    BitArray b1 = new BitArray(b);
                    for (int j = 0; j < b1.Length; j++)
                    {
                        int k = Convert.ToInt32( b1[j]);
                        if (j % 8 == 0)
                        {
                            textBox3.Text += " ";
                        }
                        textBox3.Text += k.ToString();
                        
                    }
                  
                    fs.Close();
                    sr.Close();

                }

               
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message.ToString());
            }
           
        }
        private void browsePic_Click(object sender, EventArgs e)
        {
            try
            {
                //FileStream fs1;
                string name1 = null;
                string text1 = null;
                Image img = null;
                FileStream fs1;
                StreamReader sr1;
                OpenFileDialog op2 = new OpenFileDialog();
                op2.Filter = "image files(*.bmp,*.gif,*.jpeg)|*.bmp;*.gif;*.jpg";
                if (op2.ShowDialog() == DialogResult.OK)
                {
                    name1 = op2.FileName;
                    img = Image.FromFile(name1);
                    //fs1 = new FileStream(name1, FileMode.Open, FileAccess.Read);
                    pictureBox1.Image = img;
                    //byte[] im;
                    
                    //MemoryStream ms = new MemoryStream();
                    //img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                    //im = ms.ToArray();
                    //for (int i = 0; i < im.Length; i++)
                    //{
                    //    textBox4.Text += im[i].ToString()+" ";
                    //}
                   // BitArray im1 = new BitArray(im);
                    fs1 = new FileStream(name1, FileMode.Open, FileAccess.Read);
                    sr1 = new StreamReader(fs1);
                    text1 = sr1.ReadToEnd();
                    byte[] im = Encoding.ASCII.GetBytes(text1);
                    for (int i = 0; i < 512; i++)
                    {
                        textBox4.Text += im[i].ToString() + " ";
                    }
                    BitArray im1 = new BitArray(im);
                    for(int j=0;j<512;j++)
                    {
                        textBox5.Text += Convert.ToInt32(im1[j]).ToString();
                    }
                  
                }
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message.ToString());
            }
        }





Similar Threads
Thread Thread Starter Forum Replies Last Post
image processing OCR tasleemarif C++ Programming 1 August 13th, 2007 11:09 AM
Document Image Processing (DIP) - changing image f ALcom Access 0 March 27th, 2006 06:10 AM
image processing ck C++ Programming 0 February 27th, 2005 03:33 AM
image processing ck Visual C++ 0 February 27th, 2005 03:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.