p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > .NET 3.5 and Visual Studio. 2008 > .NET Framework 3.5
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 3rd, 2009, 09:31 AM
Registered User
Points: 65, Level: 1
Points: 65, Level: 1 Points: 65, Level: 1 Points: 65, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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());
            }
        }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
image processing OCR tasleemarif C++ Programming 1 August 13th, 2007 12:09 PM
Image Processing scruffyduck BOOK: Visual Basic 2005 Programmer's Reference 1 May 19th, 2006 02:24 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



All times are GMT -4. The time now is 03:08 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc