Код:
procedure TForm1.Timer2Timer(Sender: TObject);
var
fl: TStringList;
i,j: integer;
begin
Timer2.Enabled:=false;
Fl:=TStringList.Create;
Search('****',fl);
jpg1.LoadFromFile(Fl[Fl.Count-1]);
BT1.Assign(JPG1);
jpg2.LoadFromFile('C:\***\готов.jpg');
BT2.Assign(JPG2);
for i:=0 to BT1.Height - 1 do
for j:=0 to BT1.Width - 1 do
begin
if BT1.Canvas.Pixels[j,i]=BT2.Canvas.Pixels[0,0] then
if CheckImage(i,j) then ShowMessage('Успех!');
end;
fl.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
jpg1 := TJPEGImage.Create;
jpg2 := TJPEGImage.Create;
BT1:=TBitMap.Create;
BT2:=TBitMap.Create;
end;
function TForm1.CheckImage(h, w: integer): boolean;
var
i,j,mh,mw: integer;
begin
result:=false;
mh:=h+BT2.Height;
if mh>BT1.Height then exit;
mw:=w+BT2.Width;
if mw>BT1.Width then exit;
result:=true;
for i:=h to mh do
for j:=w to mw do
begin
if (BT1.Canvas.Pixels[j,i]<>BT2.Canvas.Pixels[j-w,i-h]) then
begin
result:=false;
exit;
end;
end;
end;
Накидал код для поиска картинки в картинке, формат изображения jpg
но вырезал из изображения кусок, но он его почему то не находит хотя в одном и том же изображении находит совпадение, в чем проблема?