EmptySpace Posted July 20, 2012 Share Posted July 20, 2012 I tried examples in but I get some errors when trying example. Included things and so on... Little hard for me. I need to find bmp in picture. already downloaded so dont need to capture screen. For example from autoit logo find "T". I need to use only findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) func?Whole function.expandcollapse popup;=============================================================================== ; Function Name: findBMP ; Description: Finds a bitmap (.BMP) in another BMP file (other formats BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF should work but not tested) ; Syntax: findBMP($BMP1, $BMP2, $MatchType=TRUE) ; ; Parameter(s): $BMP1 = Filename of bitmap to search in ; $BMP2 = Filename of bitmap to search for ; $MatchType = c24RGBFullMatch, c24RGBPartialMatch, c16RGBFullMatch, c16RGBPartialMatch ; ; Return Value(s): On Success: = Returns Array List ; On Failure: = @error 1 (Control was found but there was an error with the DLLCall) ; ; Author(s): JunkEW ; ; Note(s): ; * Its never an exact match even with TRUE as last few bits are disposed in algorithm and lines below ; are not checked under assumption that those are 99.99% of the time correct ; * locking bits overview http://www.bobpowell.net/lockingbits.htm ; ToDo: ; * Transparency (when search letters on a different background) http://www.winprog.org/tutorial/transparency.html ; * Match quicker by doing a bitblt with srcinvert when first line is found (instead of checking line by line) ; * $BMP1 and $BMP2 to be HBITMAP handle as input instead of filenames (will make searching within partial screen easier) ; Example(s): ; ;=============================================================================== Func findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) Dim $fLine[1];Line number of found line(s), redimmed when second picture size is known Dim $BMP1Data="", $BMP1Width=0, $BMP1Height=0, $BMP1LineWidth=0; Dim $BMP2Data="", $BMP2Width=0, $BMP2Height=0, $BMP2LineWidth=0 Dim $foundAt = "", $matchPossible=FALSE, $matchedLines=0, $foundAtLeft=-1, $foundAtTop=-1 Dim $bestMatchLine=-1, $HighestMatchingLines=-1; For knowing when no match is found where best area is Dim $iPos=1; dim $imgBytes; local $iFuzzyDist, $searchFor, $iAbove, $bMatchPossible, $aboveLine local $j, $imgBits if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c24RGBPartialMatch) then $imgBytes=3 Else $imgBytes=2 endif ; Load the bitmap to search in getImage($BMP1, $BMP1Data, $BMP1Width, $BMP1Height, $BMP1LineWidth, $imgBytes) $BMP1Data = BinaryToString($BMP1Data) ; Load the bitmap to find getImage($BMP2, $BMP2Data, $BMP2Width, $BMP2Height, $BMP2LineWidth, $imgBytes) ;Make it strings to be able to use string functions for searching $BMP2Data = BinaryToString($BMP2Data) ;For reference of line where in BMP2FindIn a line of BMP2Find was found If $BMP2Height = 0 Then SetError(1,0,0) Return False EndIf ReDim $fline[$BMP2Height] ;If exact match check every 1 line else do it more fuzzy (as most likely other lines are unique) if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c16RGBFullMatch) Then $iFuzzyDist = 1 Else ;Check fuzzy every 10% of lines $iFuzzyDist = ceiling(($bmp2height * 0.1)) endIf $begin = TimerInit() ;Look for each line of the bitmap if it exists in the bitmap to find in For $i = 0 To $BMP2Height - 1 ;Minus imgbytes as last bits are padded with unpredictable bytes (24 bits image assumption) or 2 when 16 bits $searchFor = StringMid($BMP2Data, 1 + ($i * $BMP2lineWidth), ($BMP2lineWidth - $imgBytes)) $iPos = StringInStr($BMP1Data, $searchFor, 2, 1, $iPos) ; $iPos = StringInStr($BMP1Data, $searchFor) ;Look for all lines above if there is also a match ;Not doing it for the lines below as speed is more important and risk of mismatch on lines below is small $iAbove=1 if $iPos > 0 then $bMatchPossible=True $matchedLines=1;As first found line is matched we start counting ;Location of the match $foundAtTop = Int($iPos / $BMP1lineWidth) -$i $foundAtLeft = int(mod($iPos,$bmp1linewidth) / $imgBytes) Else $bMatchPossible=false exitloop endif while (($i+$iAbove) <= ($BMP2Height -1)) and ($bMatchPossible=True) $searchFor = StringMid($BMP2Data, 1 + (($i + $iAbove) * $BMP2lineWidth), ($BMP2lineWidth - $imgBytes)) $aboveLine = stringmid($BMP1Data,$iPos + ($iAbove * $BMP1LineWidth), ($BMP2LineWidth - $imgBytes)) if $aboveLine <> $searchFor Then $bMatchPossible=False ;To remember the area with the best match if $matchedLines >= $HighestMatchingLines Then $HighestMatchingLines = $matchedLines ;Best guess of location ;~ $foundAtTop = $fline[$i] + $i - $BMP2Height $foundAtTop = Int($iPos / $BMP1lineWidth);+ $i - $BMP2Height $bestMatchLine = Int($iPos / $BMP1lineWidth) EndIf ExitLoop EndIf $matchedLines=$matchedLines + 1 $iAbove=$iAbove+$iFuzzyDist WEnd ;If bMatchPossible is still true most likely we have found the bitmap if $bmatchPossible = True then ;~ ConsoleWrite("Could match top: " & $foundAtTop & " left: " & $foundAtLeft & " in " & TimerDiff($begin) / 1000 & " seconds" & @LF) ; MouseMove($foundatleft,$foundatTop) exitloop else ;~ consolewrite("i not matched " & $ipos & " " & $matchedlines & @crlf ) EndIf Next ;For some debugging of time ; if $bMatchPossible = True Then ; ConsoleWrite("Searching took " & TimerDiff($begin) / 1000 & " seconds " & @LF) ; Else ; ConsoleWrite("NOT FOUND Searching took " & TimerDiff($begin) / 1000 & " seconds" & @LF) ; endif ;Return an error if not found else return an array with all information if $bMatchPossible = False Then SetError(1, 0, 0) endif ; return stringsplit($bMatchPossible & ";" & $matchedLines & ";" & $foundAtLeft & ";" & $foundAtTop & ";" & $bmp2width & ";" & $BMP2Height & ";" & $HighestMatchingLines & ";" & $bestMatchLine,";") return $bMatchPossible & ";" & $matchedLines & ";" & $foundAtLeft & ";" & $foundAtTop & ";" & $bmp2width & ";" & $BMP2Height & ";" & $HighestMatchingLines & ";" & $bestMatchLine EndFunc;==>findBMP Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ;~ ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ;~ ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) Else $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 From what I can see, you have written absolutely zero code there. Did you forget to post it? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 Its way too hard! #include "findbmp.au3" $BMP1 = "C:Documents and SettingsMyDesktopAutoitNewlogo.BMP" $BMP2 = "C:Documents and SettingsMyDesktopAutoitNewT.BMP" findBMP($BMP1, $BMP2, 1) Cant think... I want to return it something if found or not. like 1 - found, 0 - not. Or #include "findbmp.au3" $BMP1 = "C:Documents and SettingsManoDesktopAutoitNaujas aplankaslogo.BMP" $BMP2 = "C:Documents and SettingsManoDesktopAutoitNaujas aplankasT.BMP" FindTester($BMP1, $BMP2, $Bool) Func FindTester($BMP1, $BMP2, $Bool) local $tResult $start = TimerInit() $tResult=findBMP($BMP1,$BMP2, $Bool) ConsoleWrite($tResult & " " & FileGetName($BMP2) & " in " & FileGetName($BMP1) & " ** matchtype " & $Bool & " time elapsed: " & TimerDiff($start) & " milliseconds" & @LF) EndFunc ? In both I get that $MatchType=$c24RGBFullMatch is undeclared (in include) Link to comment Share on other sites More sharing options...
BrewManNH Posted July 20, 2012 Share Posted July 20, 2012 Look at the sample code that was posted in that thread, he included the variable names in that instead of in his function script. Copy them from there and put them into your script. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 What variables? Link to comment Share on other sites More sharing options...
BrewManNH Posted July 20, 2012 Share Posted July 20, 2012 You're a lost cause. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 LOL yes. I dont understand anything here. You mean varialbes here? ; ** Example start ** ; Screen samples Global Const $Bitmap1Filename = @TempDir & "FULLSCREEN.bmp" Global Const $Bitmap2Filename = @TempDir & "CALCULATOR.bmp" Global Const $Bitmap3Filename = @TempDir & "BACKSPACE.bmp" ;BMP samples Global Const $Bitmap4Filename = @TempDir & "7WDS_BW.bmp" Global Const $Bitmap5Filename = @TempDir & "SEVEN_BW.bmp" Global Const $Bitmap6Filename = @TempDir & "CAT_BW.bmp" Global Const $Bitmap7Filename = @TempDir & "AUTOIT3.bmp";Make sure the homepage of autoit with 3 is visible local $calcHWND, $begin, $pos, $aWinPos, $aWinCSize, $start local $pBitmap, $BitmapData, $pixelFormat Opt("WinTitleMatchMode", 4);Matching windows by advanced options Damn it! I would never use this again if I will finish what I want... Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 I hope that is not a tantrum! What is $bool? What are the results of your testing? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 (edited) I dont know what is $bool, i just took this from example. Didint found anything more about $bool, only in this func. Tried to search in iclude and there is no var like this. Im completely lost but i need to compare or find bmp in pic and return smthg. Tried to do something over 2 hours but it leads me to bunch of errors. There is too much code like take screenshot which I dont need. So I think its only few lines of code. Edited July 20, 2012 by Edgaras Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 Ok, forget about $bool, get rid of it, just use the first two params, the third is optional. What I'm asking is, in the code you have posted, you do not even test the return. What have been the results of your call to FindBMP()? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 (edited) What result? 5errors and 10 warnings from include file. lol Edited July 20, 2012 by Edgaras Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 (edited) By the way, I also need to cut image. I got this code and I can cut it in many peaces BUT its quilty becomes low. Why and how I can fix it? Or maybe I need to convert images to bmp from gif? Code: #include ; Load PNG file as GDI bitmap _GDIPlus_Startup() $gdi_pngSrc = @ScriptDir & "a.gif" $gdi_hImage = _GDIPlus_ImageLoadFromFile($gdi_pngSrc) ; Extract image width and height from PNG $gdi_imageWidth = _GDIPlus_ImageGetWidth($gdi_hImage) $gdi_imageHeight = _GDIPlus_ImageGetHeight($gdi_hImage) ;cut images $gdi_hLeftImage = _GDIPlus_BitmapCloneArea($gdi_hImage, 0, 0, 1, $gdi_imageHeight, $GDIP_PXF32ARGB) $gdi_hRightImage = _GDIPlus_BitmapCloneArea($gdi_hImage, $gdi_imageWidth - 1, 0, 40, $gdi_imageHeight, $GDIP_PXF32ARGB) $gdi_hCenterImage = _GDIPlus_BitmapCloneArea($gdi_hImage, 40, 0, $gdi_imageWidth - 80, $gdi_imageHeight, $GDIP_PXF32ARGB) _GDIPlus_ImageSaveToFile($gdi_hLeftImage, @ScriptDir & "LEFT_1.gif") _GDIPlus_ImageSaveToFile($gdi_hRightImage, @ScriptDir & "RIGHT_1.gif") _GDIPlus_ImageSaveToFile($gdi_hCenterImage, @ScriptDir & "CENTER_1.gif") ; Release resources _WinAPI_DeleteObject($gdi_hLeftImage) _WinAPI_DeleteObject($gdi_hRightImage) _WinAPI_DeleteObject($gdi_hCenterImage) _GDIPlus_ImageDispose($gdi_hImage) _GDIPlus_Shutdown() Yes, better with bmp. Edited July 20, 2012 by Edgaras Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 What result? 5errors and 10 warnings from include file. lolWell then (LOL)Do you not think it would be wise to post these errors? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 expandcollapse popupC:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(27,55) : WARNING: $c24RGBFullMatch: possibly used before declaration. Func findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(39,72) : WARNING: $c24RGBPartialMatch: possibly used before declaration. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c24RGBPartialMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(63,69) : WARNING: $c16RGBFullMatch: possibly used before declaration. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c16RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(70,25) : WARNING: $begin possibly not declared/created yet $begin = TimerInit() ~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,164) : WARNING: $BitmapData possibly not declared/created yet $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(175,133) : WARNING: $PixelFormat possibly not declared/created yet $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(11,81) : WARNING: $BMP1 possibly not declared/created yet $BMP1 = "C:Documents and SettingsManoDesktopAutoitNaujas aplankaslogo.BMP" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(12,78) : WARNING: $BMP2 possibly not declared/created yet $BMP2 = "C:Documents and SettingsManoDesktopAutoitNaujas aplankasT.BMP" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(21,25) : WARNING: $start possibly not declared/created yet $start = TimerInit() ~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(22,40) : WARNING: $Bool: possibly used before declaration. $tResult=findBMP($BMP1,$BMP2, $Bool) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(27,55) : ERROR: $c24RGBFullMatch: undeclared global variable. Func findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(39,72) : ERROR: $c24RGBPartialMatch: undeclared global variable. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c24RGBPartialMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(63,69) : ERROR: $c16RGBFullMatch: undeclared global variable. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c16RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(22,40) : ERROR: $Bool: undeclared global variable. $tResult=findBMP($BMP1,$BMP2, $Bool) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3(23,53) : ERROR: FileGetName(): undefined function. ConsoleWrite($tResult & " " & FileGetName($BMP2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassecond test.au3 - 5 error(s), 10 warning(s) Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 With only the function and this code, what are your results? #include "findbmp.au3" Global Const $c24RGBFullMatch = 1 ;Load as 24 bits and full match Global Const $c24RGBPartialMatch = 2 ;Load as 24 bits and partial match Global Const $c16RGBFullMatch = 3 ;Load as 16 bits and full match Global Const $c16RGBPartialMatch = 4 ;Load as 16 bits and partial match $BMP1 = "C:\Documents and Settings\Mano\Desktop\Autoit\Naujas aplankas\logo.BMP" $BMP2 = "C:\Documents and Settings\Mano\Desktop\Autoit\Naujas aplankas\T.BMP" $aResul = findBMP($BMP1,$BMP2) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 13 error(s), 6 warning(s) LOL C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(27,55) : WARNING: $c24RGBFullMatch: possibly used before declaration. Func findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(39,72) : WARNING: $c24RGBPartialMatch: possibly used before declaration. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c24RGBPartialMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(63,69) : WARNING: $c16RGBFullMatch: possibly used before declaration. if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c16RGBFullMatch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,144) : WARNING: $GDIP_ILMREAD: possibly used before declaration. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,163) : WARNING: $GDIP_PXF16RGB555: possibly used before declaration. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(167,160) : WARNING: $GDIP_PXF24RGB: possibly used before declaration. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,144) : ERROR: $GDIP_ILMREAD: undeclared global variable. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,163) : ERROR: $GDIP_PXF16RGB555: undeclared global variable. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(167,160) : ERROR: $GDIP_PXF24RGB: undeclared global variable. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(145,60) : ERROR: _ScreenCapture_Capture(): undefined function. $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(146,62) : ERROR: _GDIPlus_BitmapCreateFromHBITMAP(): undefined function. $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(152,62) : ERROR: _GDIPlus_BitmapCreateFromFile(): undefined function. $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(154,75) : ERROR: _ScreenCapture_CaptureWnd(): undefined function. $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,93) : ERROR: _GDIPlus_ImageGetWidth(): undefined function. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,128) : ERROR: _GDIPlus_ImageGetHeight(): undefined function. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(165,163) : ERROR: _GDIPlus_BitmapLockBits(): undefined function. $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(181,52) : ERROR: _GDIPlus_BitmapUnlockBits(): undefined function. _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(182,36) : ERROR: _GDIPlus_ImageDispose(): undefined function. _GDIPlus_ImageDispose ($pBitmap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankasfindbmp.au3(183,35) : ERROR: _WinAPI_DeleteObject(): undefined function. _WinAPI_DeleteObject ($pBitmap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:Documents and SettingsManoDesktopAutoitNaujas aplankassearch fof bmp.au3 - 13 error(s), 6 warning(s) Link to comment Share on other sites More sharing options...
JohnOne Posted July 20, 2012 Share Posted July 20, 2012 I read them this far $c24RGBFullMatch: possibly used before declaration. And I now concur with BrewManNH, or peraps just trolling me. Either way, I'm out. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
EmptySpace Posted July 20, 2012 Author Share Posted July 20, 2012 (edited) Ok, thanks for help anyway. Little easer question. With cutting images. #include ; Load PNG file as GDI bitmap _GDIPlus_Startup() $gdi_pngSrc = @ScriptDir & "a.gif" $gdi_hImage = _GDIPlus_ImageLoadFromFile($gdi_pngSrc) ; Extract image width and height from PNG $gdi_imageWidth = _GDIPlus_ImageGetWidth($gdi_hImage) ;plotis $gdi_imageHeight = _GDIPlus_ImageGetHeight($gdi_hImage) ;ilgis ; Get Left, Right & Center from back.png $gdi_hLeftImage = _GDIPlus_BitmapCloneArea($gdi_hImage, 0, 0, 10, $gdi_imageHeight, $GDIP_PXF32ARGB) $gdi_hRightImage = _GDIPlus_BitmapCloneArea($gdi_hImage,10, 0, 20, $gdi_imageHeight, $GDIP_PXF32ARGB) $gdi_hCenterImage = _GDIPlus_BitmapCloneArea($gdi_hImage, 20, 0,30, $gdi_imageHeight, $GDIP_PXF32ARGB) _GDIPlus_ImageSaveToFile($gdi_hLeftImage, @ScriptDir & "LEFT_1.gif") _GDIPlus_ImageSaveToFile($gdi_hRightImage, @ScriptDir & "RIGHT_1.gif") _GDIPlus_ImageSaveToFile($gdi_hCenterImage, @ScriptDir & "CENTER_1.gif") ;Release resources ;_WinAPI_DeleteObject($gdi_hLeftImage) ;_WinAPI_DeleteObject($gdi_hRightImage) ;_WinAPI_DeleteObject($gdi_hCenterImage) ;_GDIPlus_ImageDispose($gdi_hImage) _GDIPlus_Shutdown() How to split image in same peaces? left is smalest, centre is biggest. Oh well, I will solve it by myself as its not so hard. Edited July 20, 2012 by Edgaras Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 20, 2012 Moderators Share Posted July 20, 2012 Edgaras, why not try reading the help file rather than wanting it to be spoon-fed to you? The help file, under _GDIPlus_BitmapCloneArea, tells you how to choose how much of the picture to take. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
BrewManNH Posted July 20, 2012 Share Posted July 20, 2012 He won't even read what's been posted in this thread, do you really think he's going to read the help file? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now