function IsHomology(bmp1, bmp2: TbitMap): boolean; type PRGBTripleArray = ^TRGBTripleArray; TRGBTripleArray = array[0..32767] of TRGBTriple; var x, y: integer; p0, p1: PRGBTripleArray; sBmp, dBmp: TBitMap; begin Result := False; if (bmp1.Height <> bmp2.Height) or (bmp1.Width <> bmp2.Width) then begin Exit; end; sBmp := TBitmap.Create; dBmp := TBitmap.Create; try sBmp.Assign(bmp1); dBmp.Assign(bmp2); sBmp.PixelFormat := pf24bit; dBmp.PixelFormat := pf24bit; for y := 0 to sBmp.Height - 1 do begin p0 := sBmp.ScanLine[y]; p1 := dBmp.ScanLine[y]; for x := 0 to sBmp.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 Result := True; end else begin Break; end; end; finally sBmp.Free; dBmp.Free; end; end;procedure TForm1.Button1Click(Sender: TObject); begin if IsHomology(SpeedButton1.Glyph, SpeedButton2.Glyph) then showmessage('相同'); end;
给你一个作为参考 tmp_str 为每一个像素点的颜色值 for i := 0 to Image1.Width do begin for j := 0 to Image1.Height do begin tmp_str := inttostr(Image1.Canvas.Pixels[i, j]);end end如果文件大小相等,则比较每一个像素的颜色值是否相等,如果都相等,则说明照片一样,否则退出
type
PRGBTripleArray = ^TRGBTripleArray;
TRGBTripleArray = array[0..32767] of TRGBTriple;
var
x, y: integer;
p0, p1: PRGBTripleArray;
sBmp, dBmp: TBitMap;
begin
Result := False; if (bmp1.Height <> bmp2.Height) or
(bmp1.Width <> bmp2.Width) then
begin
Exit;
end; sBmp := TBitmap.Create;
dBmp := TBitmap.Create;
try
sBmp.Assign(bmp1);
dBmp.Assign(bmp2);
sBmp.PixelFormat := pf24bit;
dBmp.PixelFormat := pf24bit;
for y := 0 to sBmp.Height - 1 do
begin
p0 := sBmp.ScanLine[y];
p1 := dBmp.ScanLine[y];
for x := 0 to sBmp.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
Result := True;
end
else
begin
Break;
end;
end;
finally
sBmp.Free;
dBmp.Free;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if IsHomology(SpeedButton1.Glyph, SpeedButton2.Glyph) then
showmessage('相同');
end;
楼上在比较图片的宽度和其他根本就不是图片内容阿
**************
倒。
你比较强!!
windiff也可以呀
tmp_str 为每一个像素点的颜色值 for i := 0 to Image1.Width do
begin
for j := 0 to Image1.Height do
begin
tmp_str := inttostr(Image1.Canvas.Pixels[i, j]);end
end如果文件大小相等,则比较每一个像素的颜色值是否相等,如果都相等,则说明照片一样,否则退出
效率不敢保证了。
如果你喜欢做就去取文件大小一样的,我想就算不是内容一样也差不多了
或者更简单用windows就行了
把他们放到一个文件夹里,按大小排列,在用缩略图,比较相邻的就行了
不对吗?