for y := 0 to Image1.Picture.Height-1 do
begin
l1 := Bmp1.ScanLine[y];
l2 := Bmp2.ScanLine[y];
l3 := Bmp3.ScanLine[y];
for x := 0 to Image2.Picture.Width-1 do
begin
l3[x] := l1[x] and l2[x];
end;
end;
最多进行点优化:
var
p1, p2: PByte;
i, j: gap: Integer;
begin
p1 := bmp1.scanline[bmp1.height-1];
p2 := bmp2.scanline[bmp2.height-1];
gap := bytesperscanline(bmp1.width, 8, 32) mod 4;
for i := 1 to bmp1.height do
begin
for j := 1 to bmp1.width do
begin
p1^ := p1^ and p2^;
inc(p1);
inc(p2);
end;
p1 := pointer(integer(p1)+gap);
p2 := pointer(integer(p2)+gap);
end;
end;
Procedure ImageAnd(bm1,bm2:Tbitmap);
Var bh1,bh2:tagBitmap;
ProcessSize:Integer;
Begin
Getobject(bm1.handle,Sizeof(tagBitmap),@bh1);
Getobject(bm2.handle,Sizeof(tagBitmap),@bh2);
IF (bh1.bmWidth<>bh2.bmWidth) or (bh1.bmHeight<>bh2.bmHeight)
or (bh1.bmBitsPixel<>bh2.bmBitsPixel) or (dword(bh1.bmBits)*dword(bh2.bmBits)=0) then Exit;