最近在熟悉一下TMS控件包的ImagelistBox的使用方式,为了追求高效率和扩展性,使用了TMS自带的TGDIPPictureContainer图片资源管理控件. 下面演示 GIF图片流 与 TGDIPPictureContainer图片资源管理 相互加载的实例代码
1> 初始化变量
gif_Stream : TStream ;
2> 所需控件
Image_Container : TGDIPPictureContainer ;
gif_Image : TJvGIFAnimator ;
3> 流控制
gif_Stream := TMemoryStream.Create();
Image_Container.Items[0].Picture.SaveToStream(gif_Stream) ;
gif_Stream.Position := 0 ; // 这里很重要[流位置需要重置到起始处,不然无法显示图片]
gif_Image.LoadFormStream(gif_Stream) ; // GIF控件显示图片
gif_Stream.Free() ;
这是一段非常实用的代码,通过现有的DELPHI控件,来管理多种图片资源,而不用临时转储.