DELPHI使用IDHTTP显示网络图片.doc

上传人:自*** 文档编号:126232571 上传时间:2020-03-23 格式:DOC 页数:4 大小:91KB
返回 下载 相关 举报
DELPHI使用IDHTTP显示网络图片.doc_第1页
第1页 / 共4页
DELPHI使用IDHTTP显示网络图片.doc_第2页
第2页 / 共4页
DELPHI使用IDHTTP显示网络图片.doc_第3页
第3页 / 共4页
DELPHI使用IDHTTP显示网络图片.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《DELPHI使用IDHTTP显示网络图片.doc》由会员分享,可在线阅读,更多相关《DELPHI使用IDHTTP显示网络图片.doc(4页珍藏版)》请在金锄头文库上搜索。

1、DELPHI使用IDHTTP显示网络图片:程序代码:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, IdBaseComponent, IdComponent, GifImage, Jpeg, IdTCPConnection, IdTCPClient, IdHTTP;type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Ima

2、ge1: TImage; IdHTTP1: TIdHTTP; Label1: TLabel; procedure Button1Click(Sender: TObject); private Private declarations public Public declarations end;var Form1: TForm1;implementation$R *.dfmprocedure TForm1.Button1Click(Sender: TObject);varimagestream:TMemoryStream;Buffer:Word;jpg:TjpegImage;gif:TgifI

3、mage;begin image1.Picture.Graphic:=nil ; imagestream := TMemoryStream.Create(); try IdHTTP1.Request.Accept := */*; IdHTTP1.Request.AcceptLanguage := zh-cn; IdHTTP1.Request.UserAgent:=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1); IdHTTP1.Request.Connection := Keep-Alive; IdHTTP1.HTTPOption

4、s:=IdHTTP1.HTTPOptions+hoKeepOrigProtocol; IdHTTP1.ProtocolVersion:=pv1_1; try idhttp1.Get(Edit1.Text,imagestream); except showmessage(连接失败!); exit; end; imagestream.Position:=0; if imagestream.Size = 0 then begin imagestream.Free; ShowMessage(错误!); exit; end; imagestream.ReadBuffer(Buffer,2); image

5、stream.Position:=0; if Buffer=$4D42 then /bmp begin image1.Picture.Bitmap.LoadFromStream(imagestream); end else if Buffer=$D8FF then /jpg begin jpg:=TjpegImage.Create; jpg.LoadFromStream(imagestream); image1.Picture.Assign(jpg); jpg.Free; end else if Buffer=$4947 then /gif begin gif:=TGifImage.Creat

6、e; gif.LoadFromStream(imagestream); image1.Picture.Assign(gif); gif.Free; end else if Buffer=$050A then begin ShowMessage(PCX); end else if Buffer=$5089 then begin ShowMessage(PNG); end else if Buffer=$4238 then begin ShowMessage(PSD); end else if Buffer=$A659 then begin ShowMessage(RAS); end else if Buffer=$DA01 then begin ShowMessage(SGI); end else if Buffer=$4949 then begin ShowMessage(TIFF); end else begin ShowMessage(ERROR); end; finally imagestream.Free; end;end;end.运行效果:

展开阅读全文
相关资源
相关搜索

当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号