Delphi中如何用Image控件显示网络图片


本文整理自网络,侵删。

 在窗体添加一个Image,一个IdHttp,一个Button


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, StdCtrls,Jpeg;

type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
imagestream:TMemoryStream;
jpg:TJpegImage;
begin
imagestream := TMemoryStream.Create();
jpg:=TJpegImage.Create;
idhttp1.Get('http://www.4936.cn/css/Code.aspx',imagestream);
imagestream.Position:=0;
jpg.LoadFromStream(imagestream);
image1.Picture.Assign(jpg);
end;
end.

相关阅读 >>

Delphi [函数] unicode 检查字符串是否含中文字

Delphi xe8中的firemonkey应用程序将文本复制到剪贴板

Delphi xe 分割字符串太方便了

Delphi winapi: getwindowtextlength - 获取窗口标题长度

Delphi 16进制字符串转原字符串

Delphi与sqlite3数据库

Delphi初级教程之Delphi断点调试

Delphi firedac 下的 sqlite [2] - 第一个例子

Delphi 判断字符串是否为纯数字组合

Delphi10及以上版本安装activex控件

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...