本文介绍了FireMonkey iOS RAD Studio XE2 - 显示从URL加载的表单上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将TImage放置在适用于iOS的FMX表单上,并将图像(jpg)从网址加载到该TImage中以显示在iOS应用中?
解决方案
将TButton,TImageControl和TIdHttp删除到Firemonkey表单上,此代码将从网页下拉图片:
程序TForm1.btnReadWebImgClick(发件人:TObject);
begin
ReadWebImage('http://www.gravatar.com/avatar/5af5f8c5f88c6c237745e9472a31410f?s=32&d=identicon&r=PG');
结束
程序TForm1.ReadWebImage(imgAddress:string);
var
memStream:TMemoryStream;
begin
memStream:= TMemoryStream.Create;
try
idhttp1.Get(imgAddress,memStream);
除了
ShowMessage('Image not found at:'+ imgAddress);
memStream.Free;
退出;
结束
try
memStream.Position:= 0;
ImageControl1.Bitmap.LoadFromStream(memStream);
finally
memStream.Free;
结束
结束
Is it possible to place a TImage on an FMX form for iOS and load image (jpg) from an URL into this TImage to be displayed in the iOS app?
I have tried with no success. Any hints or point in the right direction is appreciated.
解决方案
Drop a TButton, TImageControl and TIdHttp onto a Firemonkey form and this code will pull down an image from the web:
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;
这篇关于FireMonkey iOS RAD Studio XE2 - 显示从URL加载的表单上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!