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 

Bitmap to Text (Hex to Binary?)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sat Jul 19, 2008 11:42 pm    Post subject: Reply with quote

All credits are for Rajat


http://www.autohotkey.com/forum/topic4133.html&highlight=findmatrix


Code:

;___________________________________________

;GetMatrix(StartX,StartY,Dimension)
;FindMatrix(ScanStartX,ScanEndX,ScanStartY,ScanEndY,Dimension,Matrix)
;___________________________________________

;Tip : For faster searching, make sure the first pixel of matrix is
;      not abundant on the screen



;example of 3x3 matrix

SetBatchLines, -1
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

SplashImage,, W185 H50 B1, Press F4 to grab Matrix at mouse position,,
KeyWait, F4, D
MouseGetPos, mX, mY
SplashImage, Off
Matrix := GetMatrix(mX,mY,3)

Result := FindMatrix(1,800,1,600,3,Matrix)
MsgBox, %Result%

StringSplit, Result, Result, %A_Space%

Loop, 5
{
   SplashImage,, X%Result1% Y%Result2% W3 H3 B1 CWRed, .
   Sleep, 500
   SplashImage, Off
   Sleep, 500
}

ExitApp



;___________________________________________

GetMatrix(StartX,StartY,Dimension)
{
   Loop, %Dimension%
   {
      Loop, %Dimension%
      {
         PixelGetColor, Pix, %StartX%, %StartY%
         Matrix = %Matrix%|%Pix%
         StartX ++
      }
      
      StartY ++
      StartX -= %Dimension%
   }
   StringTrimLeft, Matrix, Matrix, 1
   Return %Matrix%
}
;___________________________________________

FindMatrix(ScanStartX,ScanEndX,ScanStartY,ScanEndY,Dimension,Matrix)
{
   StringSplit, Pix, Matrix, |
   Length := ScanEndY - ScanStartY
   
   ;loop for per line of screenY
   Loop, %Length%
   {
      StartX = %ScanStartX%
      EndX = %ScanEndX%

      StartY := ScanStartY + A_Index - 1
      EndY := ScanStartY + A_Index - 1
   
      ;loop for searching inside a line
      Loop
      {
         count = 0
         MatchFound = 1
         
         ;change variance and 'Fast' if not suited
         PixelSearch, pX, pY, %StartX%, %StartY%, %EndX%, %EndY%, %Pix1%, 0, Fast
         IfNotEqual, ERRORLEVEL, 0, Break
         sX = %pX%
         sY = %pY%
         
         ;loop for matching
         Loop, %Dimension%
         {
            Loop, %Dimension%
            {
               Count ++
               PixelGetColor, CurrPix, %pX%, %pY%
               
               IfNotEqual, Pix%Count%, %CurrPix%
                  MatchFound = 0
               
               IfEqual, MatchFound, 0, Break
               pX ++
            }
            IfEqual, MatchFound, 0, Break
            pY ++
            pX -= %Dimension%
         }
         
         ;match found!
         IfEqual, MatchFound, 1
         {
            Result = %sX% %sY%
            Return Result
         }
         
         StartX ++
         
         DiffX := EndX - StartX
         IfLess, DiffX, %Dimension%, Break
      }
      StartY ++
      EndY ++
   }
   Return 0
}
;___________________________________________

Back to top
Guest






PostPosted: Sat Jul 19, 2008 11:47 pm    Post subject: Reply with quote

Btw after some script changes you have your bitmap and then what.
Curious what are you going todo with it.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
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