当前位置:首页 > PHP教程 > PHP高级教程

IStream与TStream之间的相互转换

  
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;    //必加此二单元
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!