本文整理自网络,侵删。
uses Jpeg, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
{ .... }
function DownloadJPGToBitmap(const URL : string; ABitmap: TBitmap): Boolean;var idHttp: TIdHTTP; ImgStream: TMemoryStream; JpgImage: TJPEGImage;begin Result := False; ImgStream := TMemoryStream.Create; try idHttp := TIdHTTP.Create(nil); try idHttp.Get(URL, ImgStream); finally idHttp.Free; end; ImgStream.Position := 0; JpgImage := TJPEGImage.Create; try JpgImage.LoadFromStream(ImgStream); ABitmap.Assign(JpgImage); finally Result := True; JpgImage.Free; end; finally ImgStream.Free; end;end;
// Example:// Beispiel:
procedure TForm1.Button1Click(Sender: TObject);begin DownloadJPGToBitmap('http://www.sample.com/test.jpg', Image1.Picture.Bitmap);end; 相关阅读 >>
在Delphi xe2和xe3开发的程序中加入管理员权限申请
Delphi spcomm 调试串口解决总是在程序断开的时候才发送指令的问题
更多相关阅读请进入《Delphi》频道 >>