各位大哥,小弟我要将两幅图像进行比较,把颜色不同的像素找出来,不知道Delphi中如何才能高速度的实现,希望大侠们多多帮忙!分数不够小弟再送!

解决方案 »

  1.   

    BMP.SCANLINE[i];
    不是很快不过算法好点的话,可以接受!SCANLINE的用法帖子里很多,自己搜吧。
      

  2.   

    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;
      

  3.   

    楼上的朋友,我想知道可不可以把BITMAP看做一个整体,或者将其划分为几个整快,来进行比较,有没有这样的函数?
      

  4.   

    你想要不就是快速对比吗,Scanline是最快的了