procedure TForm1.Button1Click(Sender: TObject); //image1 和image2相同的大小,加载不同的两幅
//图象
var
bmp1,bmp2 :Tbitmap;
p1,p2
bytearray;
x,y:integer;
bmpwidth,bmpheight:integer;
begin
bmp1:=Tbitmap.create;
bmp2:=Tbitmap.create;
bmp1.assign(image1.picture.bitmap);
bmp1.assign(image2.picture.bitmap);
bmpwidth:=image1.Picture.Graphic.Width;
bmpheight:=image1.Picture.Graphic.height;
bmp1.pixelformat:=pf24bit;
bmp2.pixelformat:=pf24bit;
for y:=0 to bmpheight-1 do
begin
p1:=bmp1.ScanLine[y] ;
p2:=bmp2.ScanLine[y];
for x:=0 to bmpwidth-1 do
begin
p1[3*x+2]:= abs(p1[3*x+2]- p2[3*x+2]);
p1[3*x+1]:= abs(p1[3*x+1]- p2[3*x+1]);
p1[3*x]:= abs(p1[3*x]- p2[3*x]);
end;
end;
image1.Picture.Bitmap.Assign(bmp1);
bmp1.Free;
bmp2.Free;
end;
end.