Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Could anybody explain how to find X and Y Coordinates from BitmapData Array. Also how to scan a specific area of a image for specific color pixels. The Image size is 1280x1024 24bit, I need to scan in area between X: 50-150 & Y: 500-1000 for the color black. Also, I don't want to use Rectangle because after scanning the specific area if the result is success then the respective pixel's X and Y coordinates are used for calculating other pixels in the same image which are outside of this area.

Thanks
Posted
Updated 19-Dec-12 5:10am
v3

in the System.Drawing.Bitmap object you can use the GetPixel(x, y) to find the color of a pixel.


C#
Bitmap bmp = new Bitmap(@"C:\test.bmp");
for (int x = 0; x < 151; x++)
    for (int y = 500; y < 1001; y++)
        if (bmp.GetPixel(x, y).ToArgb() == Color.Black.ToArgb())
            MessageBox.Show("I found black!");
 
Share this answer
 
v4
Comments
Member 8741232 20-Dec-12 5:09am    
Hi, Thanks for making a attempt. I too am using the same, but its too slow. Thus thought of using LockBits/UnlockBits to process image faster.
This article seems to be what your looking for.
Work with bitmaps faster in C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900