|
|
 |
| .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.
|
 |

October 3rd, 2009, 09:31 AM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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());
}
}
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |