+ -
当前位置:首页 → 问答吧 → 如何将从服务器读取出来的位图数据流在Image控件上显示出来

如何将从服务器读取出来的位图数据流在Image控件上显示出来

时间:2011-12-06

来源:互联网

begin
  left := s.GetWORD;
  top := s.GetWORD;
  right := s.GetWORD;
  bottom := s.GetWORD;
  width := s.GetWORD;
  height := s.GetWORD;
  _bpp := s.GetWORD;

  bufsize := s.GetWORD;

  data := s.GetPrePointM(size);
end;
大概代码如上所示 : 位图的宽高、左上角及又下角坐标 颜色深度 位图数据(data)PByte 类型 均已得出 
求如何将其显示在我所创建的Image控件上 
 

作者: hyl601913931   发布时间: 2011-12-06

image1.picture.bitmap.LoadFromStream(astream); 
前提是你的数据流是bmp格式的

作者: funxu   发布时间: 2011-12-06

或者aBitmap: TBitmap; 
 abitmap:=tbitmap.create();
 aBitmap.LoadFromStream(aStream); 
然后把它指定给image1.picture

作者: funxu   发布时间: 2011-12-06

引用 2 楼 funxu 的回复:
或者aBitmap: TBitmap;
abitmap:=tbitmap.create();
aBitmap.LoadFromStream(aStream);
然后把它指定给image1.picture

现在我得出的是 Byte 类型的一组数据 不能做TStream对象传进去

作者: hyl601913931   发布时间: 2011-12-06

是array of byte 还是 PByte
var
 ba:array of byte;
 ms:TMemoryStream;

  ms:=TMemoryStream.Create;
  ms.WriteBuffer(ba,sizeof(ba));
  image1.picutre.bitmap.loadfromstream(ms);
 

作者: zhnglicho   发布时间: 2011-12-06

4L正解,先把byte存入流即可,另外好像一般不会使用pbyte吧

作者: funxu   发布时间: 2011-12-06

热门下载

更多