Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 05:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Need some help with image compare

Discussion on Need some help with image compare within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2012
Posts: 9
Received Thanks: 0
Need some help with image compare

I managed to write this primitive code, I know it was possible to put loops or smthg and this code make to 100lines. So everything worked fine till i wrote variables like $1, $2. When I start code it gives me general error with that dont send, microsoft shit. Any idea why its is?
Code:
#include <GDIPlus.au3>
;===============================
Global $1,$2,$3,$4,$5
;===========================================

_GDIPlus_Startup()

;=========compare with===================
$fname1 = @ScriptDir &  "\c1.bmp"
$fname2 = @ScriptDir &  "\c2.bmp"
$fname3 = @ScriptDir &  "\c3.bmp"
$fname4 = @ScriptDir &  "\c4.bmp"
$fname5 = @ScriptDir &  "\c5.bmp"
$fname6 = @ScriptDir &  "\c6.bmp"
$fname7 = @ScriptDir & "\c7.bmp"
$fname8 = @ScriptDir &  "\c8.bmp"
$fname9 = @ScriptDir &  "\c9.bmp"
$fname10 = @ScriptDir & "\c0.bmp"
;=========compare with===================

$bm1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\1.bmp") 
wHILE 1               ;$1
$bm2 = _GDIPlus_ImageLoadFromFile($fname1)
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname2)
CompareBitmaps($bm1, $bm2)
Elseif CompareBitmaps($bm1, $bm2) =  True Then
	 $1 = "1"
ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname3)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "2"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname4)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$1 = "3"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname5)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "4"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname6)
CompareBitmaps($bm1, $bm2);
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "5"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname7)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$1 = "6"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname8)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "7"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname9)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "8"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname10)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "9"
	ExitLoop
Endif
;
If CompareBitmaps($bm1, $bm2) =  True Then
	$1 = "0"
	ExitLoop
Endif

weND

;=====================================================SECOND CHECK========================================
$bm1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\2.bmp") 
wHILE 1             ;$2
$bm2 = _GDIPlus_ImageLoadFromFile($fname1)
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname2)
CompareBitmaps($bm1, $bm2)
Elseif CompareBitmaps($bm1, $bm2) =  True Then
$2 = "1"
ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname3)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "2"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname4)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$2 = "3"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname5)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "4"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname6)
CompareBitmaps($bm1, $bm2);
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "5"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname7)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "6"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname8)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "7"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname9)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "8"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname10)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$2 = "9"
	ExitLoop
Endif

If CompareBitmaps($bm1, $bm2) =  True Then
	$2 = "0"
	ExitLoop
Endif

weND

;====================================================Third========================================
$bm1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\3.bmp") 
wHILE 1            ;$3
$bm2 = _GDIPlus_ImageLoadFromFile($fname1)
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname2)
CompareBitmaps($bm1, $bm2)
Elseif CompareBitmaps($bm1, $bm2) =  True Then
	$3 = "1"
ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname3)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$3 = "2"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname4)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$3 = "3"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname5)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$3 = "4"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname6)
CompareBitmaps($bm1, $bm2);
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$3 = "5"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname7)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$3 = "6"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname8)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$3 = "7"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname9)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$3 = "8"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname10)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$3 = "9"
	ExitLoop
Endif

If CompareBitmaps($bm1, $bm2) =  True Then
$3 = "0"
	ExitLoop
Endif

weND

;=======================================fourth=====================================
$bm1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\4.bmp") 
wHILE 1         ;$4
$bm2 = _GDIPlus_ImageLoadFromFile($fname1)
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname2)
CompareBitmaps($bm1, $bm2)
Elseif CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "1"
ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname3)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "2"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname4)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "3"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname5)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$4 = "4"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname6)
CompareBitmaps($bm1, $bm2);
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "5"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname7)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$4 = "6"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname8)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$4 = "7"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname9)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$4 = "8"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname10)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "9"
	ExitLoop
Endif

If CompareBitmaps($bm1, $bm2) =  True Then
	$4 = "0"
	ExitLoop
Endif

weND

;=======================================FIFTH=====================================

$bm1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\5.bmp") 
wHILE 1        ;$5
$bm2 = _GDIPlus_ImageLoadFromFile($fname1)
iF  CompareBitmaps($bm1, $bm2) = False then
$bm2 = _GDIPlus_ImageLoadFromFile($fname2)
CompareBitmaps($bm1, $bm2)
Elseif CompareBitmaps($bm1, $bm2) =  True Then
$5 = "1"
ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname3)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
	$5 = "2"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname4)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "3"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname5)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "4"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname6)
CompareBitmaps($bm1, $bm2);
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "5"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname7)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "6"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname8)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "7"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname9)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "8"
	ExitLoop
Endif
;
iF  CompareBitmaps($bm1, $bm2) = False then

$bm2 = _GDIPlus_ImageLoadFromFile($fname10)
CompareBitmaps($bm1, $bm2)
ElseIf CompareBitmaps($bm1, $bm2) =  True Then
$5 = "9"
	ExitLoop
Endif

If CompareBitmaps($bm1, $bm2) =  True Then
$5 = "0"
	ExitLoop
Endif

weND


_GDIPlus_ImageDispose($bm1)
_GDIPlus_ImageDispose($bm2)

_GDIPlus_Shutdown()
Func CompareBitmaps($bm1, $bm2)
    $Bm1W = _GDIPlus_ImageGetWidth($bm1)
    $Bm1H = _GDIPlus_ImageGetHeight($bm1)
    $BitmapData1 = _GDIPlus_BitmapLockBits($bm1, 0, 0, $Bm1W, $Bm1H, $GDIP_ILMREAD, $GDIP_PXF32RGB)
    $Stride = DllStructGetData($BitmapData1, "Stride")
    $Scan0 = DllStructGetData($BitmapData1, "Scan0")
    $ptr1 = $Scan0
    $size1 = ($Bm1H - 1) * $Stride + ($Bm1W - 1) * 4
    $Bm2W = _GDIPlus_ImageGetWidth($bm2)
    $Bm2H = _GDIPlus_ImageGetHeight($bm2)
    $BitmapData2 = _GDIPlus_BitmapLockBits($bm2, 0, 0, $Bm2W, $Bm2H, $GDIP_ILMREAD, $GDIP_PXF32RGB)
    $Stride = DllStructGetData($BitmapData2, "Stride")
    $Scan0 = DllStructGetData($BitmapData2, "Scan0")
    $ptr2 = $Scan0
    $size2 = ($Bm2H - 1) * $Stride + ($Bm2W - 1) * 4
    $smallest = $size1
    If $size2 < $smallest Then $smallest = $size2
    $call = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest)
    _GDIPlus_BitmapUnlockBits($bm1, $BitmapData1)
    _GDIPlus_BitmapUnlockBits($bm2, $BitmapData2)
    Return ($call[0]=0)
EndFunc
plesik4s is offline  
Reply


Similar Threads Similar Threads
[Rls] Compare Script
03/15/2012 - Metin2 PServer Guides & Strategies - 25 Replies
Hey. da ich rgade nen client deutsch auf englisch mache und kb haben zu schauen welche codes etc in meinem neu sind wie im Sg client hab ichn einfaches script gemacht, das das prüft und ne neue datei aus dem wissen erstellt. ihr braucht: python 2.2(oder höher) das script de = open("C:\Users\Me\Desktop\Neuer Ordner (3)\itemdes.txt\itemdesc_de.txt", "r").readlines() sg = open("C:\Users\Me\Desktop\Neuer Ordner (3)\itemdes.txt\itemdesc_sg.txt", "r").readlines() new =...
Dibiase - New Sig/Full Size Image - [GIANT IMAGE WARNING]
10/26/2011 - General Art - 1 Replies
WARNING - SOME OF THESE IMAGES ARE MASSIVE(OVER 2000 PIXELS WIDE/1000 PIXELS HIGH). This is my latest signature collection, the full size images show the detail. Full-Size: http://img339.imageshack.us/img339/971/dibiaseful l.png Super-Sized:
Compare Between Pet
04/13/2010 - Grand Chase Philippines - 32 Replies
Ask lang po ako... ano po ba mas mainam gamitin na pet sa dungeon at sa pvp... same kc cla cute sarap gawing stuff toy ang mga to....
Value Compare 3/4
10/28/2007 - Kal Online - 3 Replies
Also wie der Titel scho sagt versuch ich rauszufinden wie ich auf die Value komm, die man eintragen muss um beispielsweise auf Staggering Blow zu kommen! Gibt hier zwar ne Liste wo drin steht, dass der Wert 3000 ist und klappt auch... aber wär doch interessant zu verstehen warum es jetzt genau 3000 is...also wo kann ich den Wert ablesen/wie find ich den raus?
Compare
07/20/2007 - Silkroad Online - 3 Replies
hi guys.. this is my character's current stats.. can other pure str bladders tell me if my stat's are okay and the things i might need to do to improve it.. i'm currently lvl 78. here's a pic of my statshttp://i110.photobucket.com/albums/n94/shif7i 7down/me.jpg



All times are GMT +2. The time now is 05:54.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.