Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello!

 

I would like to know what is the fastest way to find a pixel on my desktop. I've tried GetPixel API, but it's extremely slow. I've also tried Bitmap.GetPixel and it doesn't seem to be a difference between the two.

 

I'm trying to search for exactly one pixel on my desktop. I have the coordinate as well as the color. It has to be in a loop if you don't mind.

 

Here's how I used GetPixel:

 

Do
'Nothing
Loop Until GetPixel(hDC,X,Y) = COLOR

 

If there's anything you need to know, please ask. Thank you for this wonderful forum! :)

Posted

Ok, so this is what I have so far:

 

Dim Size As New Size(1, 1)
       Using BMP As New Bitmap(1, 1)
           Using G = Graphics.FromImage(BMP)
               Do
                   Dim FoundColor As Color
                   G.CopyFromScreen(Point, Point.Empty, Size)
                   FoundColor = BMP.GetPixel(0, 0)
                   Loop Until FoundColor.ToArgb = Color.ToArgb 

 

Still very slow... -_-. I think maybe I should use lockbits and marshall? But, I've tried and can't even come up with a working sample...

 

Do you mind posting a super fast lockbits example? :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...