RSS订阅 | 匿名投稿
您的位置:网站首页 > 图像 > 正文

delphi 下载并显示网上的图片

作者:admin 来源: 日期:2018/1/13 1:04:56 人气: 标签:

代码文件:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses GDIPOBJ, GDIPAPI, UrlMon;

procedure TForm1.Button1Click(Sender: TObject);
const
  TestPath = 'c:\temp\net.gif';                      {下载后临时存放}
  DownUrl = 'http://del.cnblogs.com/Images/xml.gif'; {要下载的文件}
var
  img: TGPImage;
  g: TGPGraphics;
begin
  if UrlDownloadToFile(nil, DownUrl, TestPath, 0, nil) = 0 then
  begin
    img := TGPImage.Create(TestPath);
    g := TGPGraphics.Create(Canvas.Handle);
    g.DrawImage(img, 10, 10, img.GetWidth, img.GetHeight);
    g.Free;
    img.Free;
  end;
end;

end.

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址:
下一篇:没有资料