Click here to Skip to main content
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 5:03am
Edited 19-Dec-12 5: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 485
1 OriginalGriff 280
2 CPallini 230
3 BillWoodruff 230
4 ChauhanAjay 149
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 20 Dec 2012
Copyright © CodeProject, 1999-2014
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