function TForm1.findimg(pBmpMain,pBmpSub: TBitmap) :Boolean;
var
Pmain,psub,ptmp: PByteArray;
x,y,z:Integer;
b: boolean;
begin
result:=false;
b:=false;
for y:=0 to pBmpMain.Height-pBmpSub.Height do
begin
Pmain := pBmpMain.ScanLine[y];
psub := pBmpSub.ScanLine[0];
for x:=0 to pBmpMain.Width-pBmpSub.Width do
begin
b:=CompareMem(@Pmain[x*3],psub,sizeof(@psub));
if b then begin
for z := 0 to pBmpSub.Height - 1 do begin
Pmain := pBmpMain.ScanLine[y+z];
psub := pBmpSub.ScanLine[z];
b:=CompareMem(@Pmain[x*3],psub,pBmpSub.Width * 3);
if not b then break;
end;
if b then Break;
end;
if b then break;
end;
if b then break;
end;
result:=b;
end;
转载于:https://blog.51cto.com/rzl01/1605263