把網路上的圖片顯示在Image如何做到?
[pascal]
var
MS: TMemoryStream;
JPEG: TJPEGImage;
Url: String;
I: Integer;
begin
ProgressBar1.Visible := True;
MS := TMemoryStream.Create;
try
JPEG := TJPEGImage.Create;
try
Url := edit1.text;
MS.Clear;
try
IdHTTP1.Get(Url, MS);
except
end;
MS.Position := 0;
JPEG.LoadFromStream(MS);
Image1.Picture.Assign(JPEG);
Application.ProcessMessages;
finally
JPEG.Free;
end;
finally
MS.Free;
end;
end;
[/pascal]