Bitmap img = new Bitmap("file name here");
Color c;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
c = img.GetPixel(i, j);
if (c == Color.White)
{
//Write space to the textfile
}
else
{
//Write dot to the textfile
}
}
}
If you do not know how to write text file, please Google/Bing first. If you cannot find it, feel free to ask then.
pradeepnt
Member
266 Points
154 Posts
image reading at pixel level
Apr 30, 2012 05:09 AM|LINK
Hi.....
I am making a project in asp.net c# 4.0 and for that i need to read an image,
if the pixel color is white then put space else put a dot and save it as text file.
Pradeep Narayan
nijhawan.sau...
All-Star
16394 Points
3170 Posts
Re: image reading at pixel level
Apr 30, 2012 05:21 AM|LINK
You need to use the Bitmap Class:
Refer to this:
http://forums.asp.net/t/1329035.aspx/1
Ruchira
All-Star
42885 Points
7019 Posts
MVP
Re: image reading at pixel level
Apr 30, 2012 10:49 AM|LINK
Hello,
See the below sample code.
Bitmap img = new Bitmap("file name here"); Color c; for (int i = 0; i < img.Width; i++) { for (int j = 0; j < img.Height; j++) { c = img.GetPixel(i, j); if (c == Color.White) { //Write space to the textfile } else { //Write dot to the textfile } } }If you do not know how to write text file, please Google/Bing first. If you cannot find it, feel free to ask then.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.pradeepnt
Member
266 Points
154 Posts
Re: image reading at pixel level
Apr 30, 2012 12:40 PM|LINK
Thanx.......
Pradeep Narayan