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 十六进制字符串转化成字符串输出hextostr strtohex(Delphi版、c#版)

Delphi的四舍五入函数

Delphi 之 定时器 (ttimer组件)

Delphi 判断两个时间差是否在一个指定范围内 -withinpastyears、withinpastmonths、withinpastweeks、withinpastdays

Delphi字符串、数组操作函数

Delphi中禁止webbrowser右键的方法

Delphi xe 横屏竖屏的管理

Delphi 利用tidencodermime tiddecodermime 组件字符串加密解密

Delphi idhttp访问百度

Delphi中interface接口的使用方法

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



打赏

取消

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

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

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

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

评论

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