【发布时间】:2014-03-19 12:28:04
【问题描述】:
我想将网络上的图像导入流(不保存)并将其显示在 TImage 上。 以下代码产生错误:
response := TMemoryStream.Create;
try
HttpGetBinary('http://www.example-url/example_image.jpg', response);
Image.Picture.LoadFromStream(response);
finally
response.Free;
end;
项目 ------- 引发异常类 'EReadError' 并带有消息: 流读取错误
这是错误指向的 Synapse 库(在 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... -
我在发帖之前试过了。结果是一样的。
标签: delphi lazarus synapse fpc