function CompBitMap : boolean;
var P : PByteArray;
begin
result := false;
1: 载入BMP文件:
Image1.Picture.BitMap.LoadFromFile('c;/sample.bmp');
Image2.Picture.BitMap.LoadFromFile('c;/sample2.bmp');
2: 比较大小,如大小不一样,则无需比较内容:
if ( Image1.Picture.BitMap.Height <> Image2.Picture.BitMap.Height )
or ( Image1.Picture.BitMap.Width <> Image2.Picture.BitMap.Width ) then Exit;
3: 逐一比较象素:
for y := 0 to Image1.Picture.BitMap.Height - 1 do
begin
p := Image1.Picture.BitMap.ScanLine[y];
p2 := Image2.Picture.BitMap.ScanLine[y];
for x := 0 to Image1.Picture.BitMap.width -1 do
begin
if P[x] <> P2[x] then exit;
end;
end;