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 

Get pixel count for specified region & color

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10716

PostPosted: Sat Sep 11, 2004 11:47 am    Post subject: Get pixel count for specified region & color Reply with quote

This small subroutine might be useful to someone. It retrieves the number of pixels in a region that match a certain color:
Code:
GPC_Color = 0x3444b0
GPC_X1 = 100
GPC_X2 = 150
GPC_Y1 = 100
GPC_Y2 = 150
Gosub GetPixelCount
if PixelCount > 7
{
...
}
return

GetPixelCount:
PixelCount = 0
GPC_X = %GPC_X1%
Loop
{
   if GPC_X > %GPC_X2%
      break
   GPC_Y = %GPC_Y1%
   Loop
   {
      if GPC_Y > %GPC_Y2%
         break
      PixelGetColor, GPC_ColorTemp, %GPC_X%, %GPC_Y%
      if GPC_ColorTemp = %GPC_Color%
         ++PixelCount
      ++GPC_Y
   }
   ++GPC_X
}
return
Back to top
View user's profile Send private message Send e-mail
ProfessorY91



Joined: 03 Mar 2008
Posts: 12
Location: Inside your mind.

PostPosted: Mon Mar 03, 2008 2:21 pm    Post subject: Thanks! Reply with quote

Is there any way to get a complete list of hex colors of a specified region?
i.e. I am looking to differentiate between a certain shade of red and blue, but red is not the majority color (and thus there are many many colors to try when i use your subroutine)

Thanks!

Um... if you could take a look at the topic labeled

Image Search Fails to recognize screenshot if trigger (game)
http://www.autohotkey.com/forum/viewtopic.php?t=29258

Would be much appreciated. An expert could tell me what im doing wrong in a few secs im sure.
_________________

Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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