有人请帮帮我,如何在C ++ builder中使用此代码? 我想从Web到TImage Control获取图像。
uses
GIFImg;
procedure TForm1.btn1Click(Sender: TObject);
var
MS : TMemoryStream;
GIf: TGIFImage;
begin
MS := TMemoryStream.Create;
GIf := TGIFImage.Create;
try
IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
Ms.Seek(0,soFromBeginning);
Gif.LoadFromStream(MS);
img1.Picture.Assign(GIF);
finally
FreeAndNil(GIF);
FreeAndNil(MS);
end;
end;
答案 0 :(得分:1)
#include <GIFImg.hpp>
void __fastcall TForm1::btn1Click(TObject *Sender)
{
TMemoryStream *MS = new TMemoryStream;
TGIFImage *GIf = new TGIFImage;
try
{
IdHTTP1->Get("http://www.google.com/intl/en_ALL/images/logo.gif", MS);
MS->Seek(0, soFromBeginning);
Gif->LoadFromStream(MS);
img1->Picture->Assign(Gif);
}
__finally
{
FreeAndNil(GIF);
FreeAndNil(MS);
}
}