怎样有程序比较两个图形Stream是否一样?请举例!(15分)

  • 主题发起人 主题发起人 sh0
  • 开始时间 开始时间
可参考:
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;

 
可参考:ImgList.Pas 1015 行
function StreamsEqual(S1, S2: TMemoryStream): Boolean;
begin
Result := (S1.Size = S2.Size) and CompareMem(S1.Memory, S2.Memory, S1.Size);
end;
 
接受答案了.
 
后退
顶部