IStream与TStream之间的相互转换
程序员文章站
2022-06-21 19:32:18
procedure tform1.button1click(sender: tobject); &nbs...
procedure tform1.button1click(sender: tobject);
var
memostream,olestream:tstream;
stream : istream;
begin
image1.picture :=nil;
image2.picture :=nil;
//显示初始照片
image1.picture.loadfromfile('c:\logo.bmp');
memostream := tmemorystream.create;
try
//将照片保存为tmemorystream
image1.picture.bitmap.savetostream(memostream);
memostream.position :=0;
//将tmemorystream转成istream
stream:=tstreamadapter.create(memostream);
//将istream转成tolestream ==tmemorystream
olestream := tolestream.create(stream);
image2.picture.bitmap.loadfromstream(olestream);
finally
memostream.free;
olestream.free;
end;
end;
///////////////////////////
uses
....................axctrls,activex; //必加此二单元