How can I tell if a stream contains a picture or not? I am working with Delphi xe8 FMX developing an iOS application. I have a listbox and am loading pictures into the items. I can do this:
if not Assigned(S) then
s:=TMemoryStream.Create;
if not Assigned(clHTTP) then
clHTTP := TIDHTTP.Create;
with clHTTP do
begin
clHTTP.HandleRedirects := True;
clHTTP.AllowCookies := True;
clHTTP.RedirectMaximum := 110000;
clHTTP.Get(someimageURL,s);
end;
s.Seek(0,soFromBeginning);
try
LItem.ItemData.Bitmap.LoadFromStream(s);
except
clHTTP.Get(DefaultImageURL,s);
s.Seek(0,soFromBeginning);
LItem.ItemData.Bitmap.LoadFromStream(s);
end;
s.Free;
clHTTP.Free;
I would prefer not to use a try-except block because it appears this causes loading of the bitmaps to be inconsistent. For example, I have to scroll the listbox items out of view, then back into view to see the pictures.