delphi – 如何将png图像加载到TImage中
发布时间:2020-12-15 09:50:03 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用Delphi XE4将png图像加载到T Image中. png以流开始:例如 Stream := TMemoryStream.Create; try Stream.LoadFromFile('c:file.png'); Stream.Position := 0; Image1.Picture.Graphic.LoadFromStream(Stream); finally Stream.Free; end; 我运
我正在尝试使用Delphi XE4将png图像加载到T
Image中. png以流开始:例如
Stream := TMemoryStream.Create; try Stream.LoadFromFile('c:file.png'); Stream.Position := 0; Image1.Picture.Graphic.LoadFromStream(Stream); finally Stream.Free; end; 我运行此代码时得到一个AV.谁能告诉我我做错了什么? 谢谢. 解决方法
在将图形加载到图片中之前,TImage.Picture.Graphic属性为nil.
您要求的内容可以通过以下方式实现: uses pngimage; Stream := TMemoryStream.Create; try // obtain png image,load from file or other.. .... Image := TPngImage.Create; try Stream.Position := 0; Image.LoadFromStream(Stream); Image1.Picture.Graphic := Image; finally Image.Free; end; finally Stream.Free; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |