Click here to Skip to main content
11,479,170 members (62,129 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5
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 19-Dec-12 6:03am
Edited 19-Dec-12 6:10am
v3
Rate this: bad
good
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!");
  Permalink  
v4
Comments
Member 8741232 at 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
good
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#[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 215
1 F-ES Sitecore 195
2 OriginalGriff 185
3 Frankie-C 120
4 DamithSL 85
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,366
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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