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 获取系统进程列表和进程所在路径

Delphi用mapfileandchecksum 函数检测 exe 或 dll 是否被修改

Delphi strtodatetime 这个函数在win7下出错

Delphi实时监视应用程序内存使用量

Delphi bintohex和hextobin

Delphi 泛型排序器 tcomparer

Delphi在目录中搜索文件

Delphi访问mysql乱码问题

Delphi 本地数据库备份与还原(Delphi)

Delphi 提升进程权限到sedebugprivilege

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



打赏

取消

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

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

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

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

评论

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