下载并显示网上的图片之二(假如是 GIF 图片) - 回复 fancy 的问题
生活随笔
收集整理的這篇文章主要介紹了
下载并显示网上的图片之二(假如是 GIF 图片) - 回复 fancy 的问题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
問題來源: http://www.cnblogs.com/del/archive/2008/07/29/1255817.html#1271328
本例效果圖:
代碼文件:
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,IdHTTP, ExtCtrls;typeTForm1 = class(TForm)Image1: TImage;IdHTTP1: TIdHTTP;Button1: TButton;procedure Button1Click(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}uses GifImg;procedure TForm1.Button1Click(Sender: TObject); constDownUrl = 'http://del.cnblogs.com/Images/xml.gif'; {要下載的文件} varstm: TMemoryStream;gif: TGIFImage; beginstm := TMemoryStream.Create;IdHTTP1.Get(DownUrl, stm);stm.Position := 0;gif := TGIFImage.Create;gif.LoadFromStream(stm);Image1.Picture.Graphic := gif;gif.Free;stm.Free; end;end. 窗體文件:
object Form1: TForm1Left = 0Top = 0Caption = 'Form1'ClientHeight = 127ClientWidth = 249Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalsePixelsPerInch = 96TextHeight = 13object Image1: TImageLeft = 10Top = 10Width = 105Height = 105endobject Button1: TButtonLeft = 152Top = 80Width = 75Height = 25Caption = 'Button1'TabOrder = 0OnClick = Button1Clickendobject IdHTTP1: TIdHTTPAllowCookies = TrueProxyParams.BasicAuthentication = FalseProxyParams.ProxyPort = 0Request.ContentLength = -1Request.Accept = 'text/html, */*'Request.BasicAuthentication = FalseRequest.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'HTTPOptions = [hoForceEncodeParams]Left = 112Top = 40end end
本例效果圖:
代碼文件:
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,IdHTTP, ExtCtrls;typeTForm1 = class(TForm)Image1: TImage;IdHTTP1: TIdHTTP;Button1: TButton;procedure Button1Click(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}uses GifImg;procedure TForm1.Button1Click(Sender: TObject); constDownUrl = 'http://del.cnblogs.com/Images/xml.gif'; {要下載的文件} varstm: TMemoryStream;gif: TGIFImage; beginstm := TMemoryStream.Create;IdHTTP1.Get(DownUrl, stm);stm.Position := 0;gif := TGIFImage.Create;gif.LoadFromStream(stm);Image1.Picture.Graphic := gif;gif.Free;stm.Free; end;end. 窗體文件:
object Form1: TForm1Left = 0Top = 0Caption = 'Form1'ClientHeight = 127ClientWidth = 249Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalsePixelsPerInch = 96TextHeight = 13object Image1: TImageLeft = 10Top = 10Width = 105Height = 105endobject Button1: TButtonLeft = 152Top = 80Width = 75Height = 25Caption = 'Button1'TabOrder = 0OnClick = Button1Clickendobject IdHTTP1: TIdHTTPAllowCookies = TrueProxyParams.BasicAuthentication = FalseProxyParams.ProxyPort = 0Request.ContentLength = -1Request.Accept = 'text/html, */*'Request.BasicAuthentication = FalseRequest.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'HTTPOptions = [hoForceEncodeParams]Left = 112Top = 40end end
總結(jié)
以上是生活随笔為你收集整理的下载并显示网上的图片之二(假如是 GIF 图片) - 回复 fancy 的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一尺多了一点点,有一点点大。打2字词
- 下一篇: 转载 为什么要有ibgp