C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

How to Convert Image to Binary String?


Posted Date: 09 Jul 2009    Resource Type: Code Snippets    Category: Graphics
Author: Sajid P KMember Level: Gold    
Rating: 1 out of 5Points: 10



Description: In the following lines, you will learn How to create Method to Convert Image to Binary String using of C# and the .NET Framework.
Basically, the program "reads" the image pixel by pixel, and where there is a pixel that is something else than white it will Append 1, else 0 in the string.


private string ConvertoToString(string imagePath)
{
string text = "";

System.Drawing.Bitmap bitMap = new Bitmap(imagePath);

for (int i = 0; i < bitMap.Height; i++)
{
for (int j = 0; j < bitMap.Width; j++)
{
if (bitMap.GetPixel(j, i).A.ToString() == "255" && bitMap.GetPixel(j, i).B.ToString() == "255" && bitMap.GetPixel(j, i).G.ToString() == "255" && bitMap.GetPixel(j, i).R.ToString() == "255")
{
text = text + "0";
}
else
{
text = text + "1";
}
}
text = text + "";
}

return ( text);

}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Image  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Resize an image
Previous Resource: Draw the shapes
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use