AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Imagesearch hack?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Ceeesar
Guest





PostPosted: Sun May 13, 2007 4:48 pm    Post subject: Imagesearch hack? Reply with quote

I'd like to search for an image with 1 white pixel and no black pixels around the white pixel. Those other pixels can have any color except for black. Is there any way to do this?
Back to top
raven-gm



Joined: 25 Mar 2007
Posts: 24

PostPosted: Sun May 13, 2007 5:23 pm    Post subject: Reply with quote

Sure; use PixelSearch instead. Whenever you get a White pixel, call a subroutine (or a function) that checks all the pixels around it to see if they're black.

Code:

CheckForBlackAround(PxlX,PxlY)
{
X1 := PxlX - 1,Y1 := PxlY - 1 ; Start the search one pixel above and to the left of the passed pixel
X2 := PxlX + 1,Y2 := PxlY + 1 ;  End it one pixel below and one pixel to the right of the passed pixel

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, 0x000000
if errorlevel = 1
Return true ; the color was not found
if errorlevel = 0
return false ; the color was found
if errorlevel = 2
Msgbox There was an error conducting the search
Return
}


Here's an (untested) function that takes a pixel, and checks to see if the area around it (Including it, so don't pass it black pixels!) has any black pixels in it.

To do what you want, you'd want to do a PixelSearch for white pixels, then run this test on them.
If it fails the test, do another pixelsearch without including that pixel (like the rest of that column, then all the other pixels to the right of that column), then call the funciton again.

Although, because there are a lot of white pixels around (most of the time, anyways, but from what it sounds like, you need this for a game...), you might want to use the [fast] option of PixelSearch.[/code]
_________________
I would like to think that I know what I'm doing, but there's just to much stuff I've yet to learn...
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group