procedure TForm1.Button1Click(Sender: TObject); type PRGBTripleArray = ^TRGBTripleArray; TRGBTripleArray = array[0..32767] of TRGBTriple; var x,y:integer; p0,p1: PRGBTripleArray; begin Image1.Picture.LoadFromFile('C:\WINNT\wallpaper.bmp'); Image2.Picture.LoadFromFile('C:\WINNT\wallpaper1.bmp'); if (Image1.Picture.Bitmap.Height<>Image2.Picture.Bitmap.Height)or (Image1.Picture.Bitmap.Width <>Image2.Picture.Bitmap.Width ) then begin caption:='不同'; Exit; end; Image1.Picture.Bitmap.PixelFormat :=pf24bit; Image2.Picture.Bitmap.PixelFormat :=pf24bit; for y:=0 to Image1.Picture.Bitmap.Height -1 do begin p0:=Image1.Picture.Bitmap.ScanLine[y]; p1:=Image2.Picture.Bitmap.ScanLine[y]; for x:=0 to Image1.Picture.Bitmap.Width -1 do if (p0[x].rgbtBlue =p1[x].rgbtBlue)and (p0[x].rgbtGreen =p1[x].rgbtGreen )and (p0[x].rgbtRed =p1[x].rgbtRed ) then begin caption:='相同'; end else begin caption:='不同'; Exit; end; end;end;
不是很快不过算法好点的话,可以接受!SCANLINE的用法帖子里很多,自己搜吧。
type
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array[0..32767] of TRGBTriple;
var
x,y:integer;
p0,p1: PRGBTripleArray;
begin
Image1.Picture.LoadFromFile('C:\WINNT\wallpaper.bmp');
Image2.Picture.LoadFromFile('C:\WINNT\wallpaper1.bmp'); if (Image1.Picture.Bitmap.Height<>Image2.Picture.Bitmap.Height)or
(Image1.Picture.Bitmap.Width <>Image2.Picture.Bitmap.Width ) then
begin
caption:='不同';
Exit;
end; Image1.Picture.Bitmap.PixelFormat :=pf24bit;
Image2.Picture.Bitmap.PixelFormat :=pf24bit;
for y:=0 to Image1.Picture.Bitmap.Height -1 do
begin
p0:=Image1.Picture.Bitmap.ScanLine[y];
p1:=Image2.Picture.Bitmap.ScanLine[y];
for x:=0 to Image1.Picture.Bitmap.Width -1 do
if (p0[x].rgbtBlue =p1[x].rgbtBlue)and
(p0[x].rgbtGreen =p1[x].rgbtGreen )and
(p0[x].rgbtRed =p1[x].rgbtRed ) then
begin
caption:='相同';
end
else
begin
caption:='不同';
Exit;
end; end;end;