How to load a png image into a TImage
问题 I am trying to load a png image into a TImage with Delphi XE4. The png starts off in a stream: E.g. Stream := TMemoryStream.Create; try Stream.LoadFromFile('c:\file.png'); Stream.Position := 0; Image1.Picture.Graphic.LoadFromStream(Stream); finally Stream.Free; end; I get an AV when I run this code. Can anyone tell me what I'm doing wrong? Thanks. 回答1: The TImage.Picture.Graphic property is nil until you load a graphic into the Picture . What you are asking for can be achieved as follows: