반응형
uses
IdURI, JPEG, IdHTTP ;
procedure TForm1.Button1Click(Sender: TObject);
var
ImageURL: String;
begin
ImageURL := 'http://eventzone.hanafos.com/images/8spot_131x121.gif';
GetWebImage(ImageURL);
end;
procedure TForm1.GetWebImage(AImageURL: String);
var
ImageStream: TMemoryStream;
URI: TidURI;
ImagePath: String;
JPI: TJPEGImage;
HTTP: TIdHTTP;
begin
ImageStream := TMemoryStream.Create;
HTTP := TIdHTTP.Create(Self);
try
HTTP.Get(AImageURL, ImageStream);
ImageStream.Position := 0;
JPI := TJPEGImage.Create;
try
JPI.LoadFromStream(ImageStream);
finally
Image1.Picture.Assign(JPI);
JPI.Free;
end;
finally
ImageStream.Free;
HTTP.Free;
end;
end;
반응형