1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| var
Found :boolean;
B1, B2 :TBitmap;
P1, P2, P11, P21 :PByte;
BpS :integer;
X1, Y1, Y2 :integer;
begin
Found := FALSE;
B1 := Image1.Picture.Bitmap;
B2 := Image2.Picture.Bitmap;
P2 := B2.ScanLine[0];
BpS := BytesPerScanline(B1.Width, 24, 32);
for y1 := 0 to B1.Height -B2.Height -1 do
begin
P1 := B1.ScanLine[y1];
for x1 := 0 to B1.Width -B2.Width -1 do
begin
if CompareMem(P1, P2, B2.Width *3) then
begin
P11 := P1;
for y2 := 1 to B2.Height -1 do
begin
P21 := B2.ScanLine[y2];
Dec(P11, BpS);
Found := CompareMem(P11, P21, B2.Width *3);
if not Found then Break;
end;
if Found then
begin
Image1.Canvas.Rectangle(TRect.Create(Point(x1, y1), B2.Width -1, B2.Height -1));
ShowMessage('Trouvé');
Exit;
end;
end;
Inc(P1, 3);
end;
end;
ShowMessage('Pas trouvé !');
end; |
Partager