delphi 下载一个jpg图片保存为bmp图片


本文整理自网络,侵删。

 
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;

相关阅读 >>

print documents from Delphi - print pdf, doc, xls, html, rtf, docx, txt

Delphi调用winapi: getsystemmetrics - 获取系统度量等数值信息

你的软件源代码安全吗?

Delphi dos批命令打开应用程序同时关闭dos窗口本身

Delphi 时间与相关类型(3): tfiletime、tsystemtime 及 dos 时间

Delphi 蜂鸣器发声

Delphi 调用sql和mysql存储过程

Delphi字符串中取数字

Delphi memo 控件光标定位

Delphi 列出dbgrideh被选中的值

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...