如何从Delphi中的URL获取图像 [英] How to get images from URL in Delphi

查看:286
本文介绍了如何从Delphi中的URL获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找任何代码示例,显示如何将图像从URL拉到Delphi TImage组件。

I am looking for any code samples that show how to pull images from URL into Delphi TImage component.

谢谢,

推荐答案

在TMemoryStream和Indy组件的帮助下。

With help of TMemoryStream and Indy component.

uses
  GIFImg;

procedure TForm1.btn1Click(Sender: TObject);
var
  MS : TMemoryStream;
  GIf: TGIFImage;
begin
  MS := TMemoryStream.Create;
  GIf := TGIFImage.Create;
  try
    IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
    Ms.Seek(0,soFromBeginning);       
    Gif.LoadFromStream(MS);
    img1.Picture.Assign(GIF);

  finally
    FreeAndNil(GIF);
    FreeAndNil(MS);
  end;
end;

这篇关于如何从Delphi中的URL获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆