unit imgCompareThread;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.StdCtrls,
Vcl.ComCtrls,
Vcl.Menus,
Vcl.ImgList,SelectKit,picturehelper;
type
TImageSearch =
class(TThread)
private
{ Private-Deklarationen }
protected
procedure Execute;
override;
public
constructor Create(CreateSuspended : boolean ;
var SearchBMP,ScreenBMP : TBitmap;
var xyPoint : TPoint);
overload;
end;
implementation
{ TImageSearch }
procedure TImageSearch.Execute;
begin
{ Thread-Code hier einfügen }
NameThreadForDebugging(AnsiString(inttostr(GetTickCount)));
end;
constructor TImageSearch.Create(CreateSuspended: Boolean;
var SearchBMP: TBitmap;
var ScreenBMP: TBitmap;
var xyPoint: TPoint);
var
x,y: Integer;
tempBMP : Tbitmap;
rectSource,rectDest : TRect;
toBreak : boolean;
i: Integer;
k: Integer;
begin
inherited Create (CreateSuspended) ;
toBreak := false;
// ******************************************************************************
// oben links suchen
// ******************************************************************************
Try
//showMessage('Suche');
FreeOnTerminate := true;
// Declaration
tempBMP := Tbitmap.Create;
tempBMP.Width := SearchBMP.Width;
tempBMP.Height := SearchBMP.Height;
tempBMP.PixelFormat := SearchBMP.PixelFormat;
for x := 0
to ScreenBMP.Width-tempBMP.Width-1
do
begin
if toBreak
then break;
for y := 0
to ScreenBMP.Height-tempBMP.Height-1
do
begin
// Ausschnittsbereich festlegen
rectDest := rect(0,0,tempBmp.Width,tempBmp.Height);
rectSource := rect(x,y,x+tempBmp.Width,y+tempBmp.Height);
tempBmp.Canvas.CopyMode := cmSrcCopy;
// Ausschnittsbereich kopieren rectSource
tempBmp.Canvas.CopyRect(rectDest,ScreenBMP.Canvas,rectSource);
//imgTemp.Picture.Bitmap.Assign(tempBMP);
if Compare2Bitmaps(80,SearchBMP,tempBMP) = ceOK
then
begin
//Label1.Caption := 'Zeit: '+FloatToStr((GetTickCount - startTime)/1000)+' s';
toBreak := true;
//showMessage(inttostr(x)+'-'+inttostr(y));
xyPoint.X := x;
xyPoint.Y := y;
break;
end;
end;
end;
Finally
tempBMP.Free;
End;
end;
end.