是否可以在iOS的FMX表单上放置TImage并将URL中的图像(jpg)加载到要在iOS应用中显示的TImage中?
我尝试没有成功。任何提示或指向正确方向的方法都值得赞赏。
最佳答案
将TButton,TImageControl和TIdHttp拖放到Firemonkey表单上,此代码将从网络上提取图像:
procedure TForm1.btnReadWebImgClick(Sender: TObject);
begin
ReadWebImage('http://www.gravatar.com/avatar/5af5f8c5f88c6c237745e9472a31410f?s=32&d=identicon&r=PG');
end;
procedure TForm1.ReadWebImage(imgAddress: string);
var
memStream: TMemoryStream;
begin
memStream := TMemoryStream.Create;
try
idhttp1.Get (imgAddress,memStream);
except
ShowMessage('Image not found at:'+imgAddress);
memStream.Free;
exit;
end;
try
memStream.Position := 0;
ImageControl1.Bitmap.LoadFromStream(memStream);
finally
memStream.Free;
end;
end;