我想从网络获取图像并将其显示为流(不保存)并在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