可参考:
function TGraphic.Equals(Graphic: TGraphic): Boolean;
var
MyImage, GraphicsImage: TMemoryStream;
begin
Result := (Graphic <> nil) and (ClassType = Graphic.ClassType);
if Empty or Graphic.Empty then
begin
Result := Empty and Graphic.Empty;
Exit;
end;
if Result then
begin
MyImage := TMemoryStream.Create;
try
WriteData(MyImage);
GraphicsImage := TMemoryStream.Create;
try
Graphic.WriteData(GraphicsImage);
Result := (MyImage.Size = GraphicsImage.Size) and
CompareMem(MyImage.Memory, GraphicsImage.Memory, MyImage.Size);
finally
GraphicsImage.Free;
end;
finally
MyImage.Free;
end;
end;
end;