Click here to Skip to main content
13,559,503 members
Rate this:
Please Sign up or sign in to vote.
See more:

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.

Posted 19-Dec-12 5:03am
Updated 19-Dec-12 5:10am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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!");
User-8703426 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This article seems to be what your looking for.
Work with bitmaps faster in C#[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02-2016 | 2.8.180527.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100