我想從網絡獲取圖像並將其顯示爲流(不保存)並在TImage上顯示。 下面的代碼產生一個錯誤:使用Synapse從網絡獲取圖像並進行顯示
response := TMemoryStream.Create;
try
HttpGetBinary('http://www.example-url/example_image.jpg', response);
Image.Picture.LoadFromStream(response);
finally
response.Free;
end;
項目-------引發的異常類「EReadError」與消息: 流讀取錯誤
這是在突觸庫中的功能(在picture.inc)的錯誤點:
function TPicFileFormatsList.FindByStreamFormat(Stream: TStream): TGraphicClass;
var
I: Integer;
begin
for I := Count - 1 downto 0 do
begin
Result := GetFormats(I)^.GraphicClass;
if Result.IsStreamFormatSupported(Stream) then // <<<<<< this is the error line
Exit;
end;
Result := nil;
end;
將流位置設置爲開頭,然後將其加載到圖像上。像'response.Position:= 0; Image.Picture.LoadFromStream ...' – TLama
我在這裏發佈之前試過。結果是一樣的。 – user3327194