• Advertisement
Sign in to follow this  

Alternative to GetPixel

This topic is 3053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to read portions of the desktop in my program, but I am unsure as to how to go about doing this in a manner that is faster than using GetPixel for each individual pixel. At one point I was grabbing a rectangle using BitBlt and storing it into a BITMAP, but that was equally slow. The windows magnifier program (start->programs->accessories->accessibility) seems to do it virtually instantly, but I figured that maybe it's not actually reading the screen data into memory that the program itself accesses, eg: it's simply blitting video memory around, instead of to system memory. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Fastest way I know of:

1) Create new DC linked to bitmap object
2) BitBlit the screen DC data into bitmap's DC
3) Use GetDIBits to copy the data from bitmap DC into raw data buffer

Share this post


Link to post
Share on other sites
You can't successfull use GetPixel for any amount of bulk image processing.
It's like wanting to buy 1 cup of rice by repeatedly going to the shop to buy a single grain, carrying that home, and going back to the shop to buy the next grain... etc
I.e. It takes forever because it has such a high overhead per call. A BitBlt on the other hand would usually be very fast. If the bit-depths of the bitmaps are different etc then it can slow down a litle, but it still shouldn't be close to as slow as GetPixel calls unless you perhaps were using it for a very small area.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement