flat assembler
Message board for the users of flat assembler.

Index > Windows > (faster) GetPixel alternative?

Author
Thread Post new topic Reply to topic
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 13 Mar 2006, 23:49
i need to scan a region of a running window (a game to be specific) but a loop of GetPixel is terribly slow, any alternatives?

_________________
redghost.ca
Post 13 Mar 2006, 23:49
View user's profile Send private message AIM Address MSN Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 14 Mar 2006, 04:27
A better way would be to get a DIB array of the whole image and then scan the array. This way you are avoiding repeated API calls to a slow function such as GetPixel.

Here's a few links that will help you.

-This one shows the process (not in assembly but easily portable).
http://www.codeguru.com/cpp/g-m/gdi/article.php/c3693/

-MSDN articles on the subject.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7gms.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_87eb.asp
Post 14 Mar 2006, 04:27
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 14 Mar 2006, 16:26
I'm not sure if it would work for you, but maybe a good solution is to calculate some hash value (like crc32) from the correct rectangle (treat pixel by pixel just as buffer with some bytes) and do the same with the one you're looking for. Than you have to compare just one dword. Of course this solution isn't always perfectly correct, but for most cases is ok. At least theoretically Smile
Post 14 Mar 2006, 16:26
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 15 Mar 2006, 08:11
Hash is not the way to go with OCR or other image-recognition. You need to filter out the "definately-NO" situations as quickly as you can and compare you search with the image only incrementally.

Its like looking for a word "for" in this sentence. You don't compare "for" with every part of the sentence, but rather search for "f", then check if the next is "o" etc. and on every error you fall-back to "f".

Anyhow the same goes for gamehacks etc. Razz (sorry, I don't have a clue what you are doing). By searching for the first matching colour only then will you try to match it with the rest of you search-image.
Post 15 Mar 2006, 08:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Mar 2006, 09:32
So maybe apply something like Boyer-Moore algorithm? Perhaps two-dimensional variant. Smile
Post 15 Mar 2006, 09:32
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 18 Mar 2006, 02:55
Madis731 wrote:

Anyhow the same goes for gamehacks etc. Razz (sorry, I don't have a clue what you are doing).


apparently you do know what i'm doing Twisted Evil

thanks for the info guys (feel free to expand more on algorithms and etc) but i dont think crc or checksum would work as the coloured parts will be in completely different positions of the screen with a constant changing background as different parts of the 3d world are rendered

_________________
redghost.ca
Post 18 Mar 2006, 02:55
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.