如标题

解决方案 »

  1.   

    大概方法
    1.逐点比较,这个是最基础的办法了
    2.crc校验
    3.如果是两个.bmp文件,不是在delphi中打开的图像,可以参考一下文件比较的方法,crc或md5
      

  2.   

    如果图像很小的话,比如ico,可以将内容读到一个数组中,然后比较两个数组是否相等这些都是一些想法,具体的要实际实验一下
      

  3.   

    有代码吗?
    如:
      var
        ACanvas: TControlCanvas;
        ABitmap1,ABitmap2: TBitmap;
    begin
        ABitmap1 := TBitmap.Create;
        ABitmap2 := TBitmap.Create;    ACanvas := TControlCanvas.Create;
     
          ABitmap1.Width := a_Width;
          ABitmap1.Height := a_Height;  
          ABitmap2.Width := b_Width;
          ABitmap2.Height := b_Height;
    取得图片
          ACanvas.Control := 图片;
          ACanvas.Draw(0, 0, ABitmap1);
          ACanvas.Draw(0, 0, ABitmap2);
    下面如何比较?
    。。
      

  4.   

    大概是比较位图的Canvas.Pixels[x,y]的色值
      

  5.   

    大致是这么个意思      for i := 1 to ABitmap1.Width do
          begin
            for j := 1 to ABitmap1.Height do
            begin
              if ABitmap1.Canvas.Pixels[i,j] <> ABitmap2.Canvas.Pixels[i,j]
              begin
                ShowMessage('no');
                Break;
              end;
            end;
          end;
      

  6.   

    用流把文件打开,循环读一定大小到内存,用CompareMem比较
      

  7.   

    也许还可以打个相似的分数       for i := 1 to ABitmap1.Width do
          begin
            for j := 1 to ABitmap1.Height do
            begin
              if ABitmap1.Canvas.Pixels[i,j] <> ABitmap2.Canvas.Pixels[i,j] then
                n:=n+1
              else
                y:=y+1;
            end;
          end;
        分数=(y/(y+n))*100;
      

  8.   

    这里有参考代码:http://www.52delphi.com/list.asp?ID=32,你看看对你是否有帮助
      

  9.   

    这是查到的参考代码,大家看看
    function IsBmpSame(bmp1,bmp2: TBitmap): Boolean;
    var
      i,j: Integer;
      ScanLine1,ScanLine2: PByteArray;
      Count: Integer;
    begin
      Result := (bmp1.Height = bmp2.Height) and
                (bmp1.Width = bmp2.Width) and
                (bmp1.PixelFormat = bmp2.PixelFormat);
      if Result then
      begin
        i := Integer(bmp1.PixelFormat);
        if i < 4 then
          i := 4
        else if i = 4 then
          inc(i);
        Count := (i - 3) * bmp1.Width - 1;    for i:=0 to bmp1.Height-1 do
        begin
          ScanLine1 := bmp1.ScanLine[i];
          ScanLine2 := bmp2.ScanLine[i];
          for j := 0 to Count do
            if ScanLine1[j] <> ScanLine2[j] then
            begin
              Result := False;
              Exit;
            end;
        end;
      end;
    end;
    本文来自Delphi之窗资源分享,原文地址:http://www.52delphi.com
      

  10.   


    function Compare2Line(pBmpMain,pBmpSub: TBitmap): Boolean;
    var
      b: boolean;
      i,j: integer;
      ptr1,ptr2: Pointer;
    begin
      for i := 0 to pBmpMain.Height - 1 do
      begin
        ptr1 := pBmpMain.ScanLine[i];
        ptr2 := pBmpSub.ScanLine[i];
        b := CompareMem(ptr1,ptr2,pBmpMain.Width * 3);
        if not b then break;
      end;
      Result := b;
    end;