Skip to main content
gamedev.net
🔒 Locked

comparing two pixels

Started by WWakerFAN Dec 13, 2005 at 8:29 AM 7 replies 1.3k views
Original Post
WWakerFAN
WWakerFAN
i've been using the gdi getpixel function to retrieve the colors of the pixels to compare them, i was wondering whether there may be faster ways of doing it
ZQJ
ZQJ
For very small numbers of pixels probably not. If you want to grab all the pixels in your window, you probably want to do something like create a HBITMAP using CreateCompatibleBitmap, select it into the device context and use GetDIBits. I'm not entirely sure if that will work, it's been a long time since I've done this and the MSDN documentation isn't completely clear - you might have to redraw your window after selecting the bitmap in for instance.
Modena_au
Modena_au
If it where me, I would get the uncompressed data of the image and compare them manually. GDI functions incure a pretty high overhead, and while good enough for general app building, I tend to stay away from them when performance is an issue.
ebikhan
ebikhan
I dont want to use the GDI functions while capturing the screen shot. Any other method to use it like reading Screen Buffer. How can i do it in C/C++ ?
ThanksBest Regards,
Modena_au
Modena_au
Quote:
Original post by ebikhan
I dont want to use the GDI functions while capturing the screen shot. Any other method to use it like reading Screen Buffer. How can i do it in C/C++ ?


You can't do it just in C/C++. You'd have to copy your rendering surface into an image and save it to disk using one whichever API you are using. Seeing as how I don't know what APIs you're using, I'm affraid I can't get too much more specific than that.
Anon Mike
Anon Mike
The OS will not let you directly read the screen buffer. You have to go through one of the standard graphics API's - GDI, DirectX, or OpenGL.
-Mike
Zahlman
Zahlman
What exactly are you trying to do? It may make more sense to calculate for yourself what the "screen looks like" in an offscreen buffer (or if you're double-buffering or doing something else along those lines, just consult a buffer that you already have!) and compare values within an array of pixel data directly.
ebikhan
ebikhan
Well my task is to capture screen shot of complete screen while my app will be running ... I dont want any performance issues ... so any method of dirtecly accessing the Screen Buffer ... I dont want to read not writing it ... So OS shud have no prob with it.
ThanksBest Regards,
WWakerFAN
WWakerFAN
Quote:
Original post by ZQJ
For very small numbers of pixels probably not. If you want to grab all the pixels in your window, you probably want to do something like create a HBITMAP using CreateCompatibleBitmap, select it into the device context and use GetDIBits. I'm not entirely sure if that will work, it's been a long time since I've done this and the MSDN documentation isn't completely clear - you might have to redraw your window after selecting the bitmap in for instance.


yeah, i asked because the amount of pixels i'll be comparing will be around 225000000-400000000... lol

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.