width:=SubBmp.Width; Height:=SubBmp.Height; setlength(SData,MotherBmp.Height+1); setlength(TData,SubBmp.Height+1); same:=false; if SubBmp.PixelFormat<>MotherBmp.PixelFormat then begin same:=true; NewSubBmp:=TBitmap.Create; NewSubBmp.PixelFormat:=motherbmp.PixelFormat; NewSubBmp.Width:=width; NewSubBmp.Height:=height; BitBlt(NewSubBmp.Canvas.Handle,0,0,width,height, SubBmp.Canvas.Handle,0,0,SRCCopy); end else NewSubBmp:=SubBmp; for i:=0 to MotherBmp.Height-1 do SData[i]:=MotherBmp.ScanLine[i]; for i:=0 to newSubBmp.Height-1 do TData[i]:=NewSubBmp.ScanLine[i]; minc:=maxint; tmpc:=maxint; minx:=-1; miny:=-1; PixelFormat:= MotherBmp.PixelFormat; for i:=0 to MotherBmp.Height-NewSubBmp.Height-1 do begin for j:=0 to MotherBmp.Width-newSubBmp.Width-1 do begin case PixelFormat of pf24bit: tmpc:=GetDataDifference(SData,j*3,i,Width*3,Height,TData,0,0,use); pf32bit: tmpc:=GetDataDifference(SData,j*4,i,Width*4,Height,TData,0,0,use); pf16bit: tmpc:=GetDataDifference(SData,j*2,i,Width*2,Height,TData,0,0,use); pf8bit : tmpc:=GetDataDifference(SData,j,i,Width,Height,TData,0,0,use); pf15bit: tmpc:=GetDataDifference(SData,j*2,i,Width*2,Height,TData,0,0,use); end; if tmpc>minc then begin minc:=tmpc; minx:=i; miny:=j; end; end; end; ResultRect:=rect(minx,miny,minx+width,miny+height); result:=minc; if same then NewSubBmp.Free;
Height:=SubBmp.Height; setlength(SData,MotherBmp.Height+1);
setlength(TData,SubBmp.Height+1); same:=false;
if SubBmp.PixelFormat<>MotherBmp.PixelFormat then
begin
same:=true;
NewSubBmp:=TBitmap.Create;
NewSubBmp.PixelFormat:=motherbmp.PixelFormat;
NewSubBmp.Width:=width;
NewSubBmp.Height:=height;
BitBlt(NewSubBmp.Canvas.Handle,0,0,width,height,
SubBmp.Canvas.Handle,0,0,SRCCopy);
end
else
NewSubBmp:=SubBmp; for i:=0 to MotherBmp.Height-1 do
SData[i]:=MotherBmp.ScanLine[i];
for i:=0 to newSubBmp.Height-1 do
TData[i]:=NewSubBmp.ScanLine[i]; minc:=maxint;
tmpc:=maxint;
minx:=-1;
miny:=-1;
PixelFormat:= MotherBmp.PixelFormat;
for i:=0 to MotherBmp.Height-NewSubBmp.Height-1 do
begin
for j:=0 to MotherBmp.Width-newSubBmp.Width-1 do
begin
case PixelFormat of
pf24bit: tmpc:=GetDataDifference(SData,j*3,i,Width*3,Height,TData,0,0,use);
pf32bit: tmpc:=GetDataDifference(SData,j*4,i,Width*4,Height,TData,0,0,use);
pf16bit: tmpc:=GetDataDifference(SData,j*2,i,Width*2,Height,TData,0,0,use);
pf8bit : tmpc:=GetDataDifference(SData,j,i,Width,Height,TData,0,0,use);
pf15bit: tmpc:=GetDataDifference(SData,j*2,i,Width*2,Height,TData,0,0,use);
end;
if tmpc>minc then
begin
minc:=tmpc;
minx:=i;
miny:=j;
end;
end;
end;
ResultRect:=rect(minx,miny,minx+width,miny+height);
result:=minc; if same then NewSubBmp.Free;