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
fScreenBMP : TBitmap;
fSearchBMP : TBitmap;
fxyPoint : Tpoint;
{ Private-Deklarationen }
protected
procedure Execute;
override;
public
//constructor Create(CreateSuspended : boolean ;var SearchBMP,ScreenBMP : TBitmap;var xyPoint : TPoint);overload;
constructor Create(CreateSuspended: boolean);
overload;
property ScreenBMP : TBitmap
read FScreenBMP
write FScreenBMP;
property SearchBMP : TBitmap
read FSearchBMP
write FSearchBMP;
property xyPoint : TPoint
read fxyPoint
write fxyPoint;
end;
implementation
{ TImageSearch }
procedure TImageSearch.Execute;
var
x,y: Integer;
tempBMP : Tbitmap;
rectSource,rectDest : TRect;
toBreak : boolean;
i: Integer;
k: Integer;
begin
toBreak := false;
// ******************************************************************************
// Inventar oben links suchen
// ******************************************************************************
Try
// Declaration
tempBMP := Tbitmap.Create;
tempBMP.Width := FSearchBMP.Width;
tempBMP.Height := FSearchBMP.Height;
tempBMP.PixelFormat := FSearchBMP.PixelFormat;
for x := 0
to FScreenBMP.Width-tempBMP.Width-1
do
begin
if toBreak
then break;
for y := 0
to FScreenBMP.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(60,FSearchBMP,tempBMP) = ceOK
then
begin
toBreak := true;
fxypoint.x := x;
fxypoint.y := y;
with Tform.Create(
nil)
do
begin
FormStyle := fsStayOnTop;
Name := '
frmSelection2';
Position := poDesigned;
left := x-3;
top := y-3;
Width := 56;
Height := 56;
borderstyle := bsNone;
color := clWhite;
for k := 0
to 5
do
begin
visible := true;
sleep(100);
visible := false;
sleep(100);
end;
free;
end;
break;
end;
end;
end;
Finally
tempBMP.Free;
End;
end;
constructor TImageSearch.Create(CreateSuspended: Boolean);
begin
fScreenBMP := TBitmap.Create;
fSearchBMP := TBitmap.Create;
inherited Create(CreateSuspended);
end;
end.