我为每个 URL 携带图像并显示 TImage 。我将使用 JPG、GIF 和 PNG。但我不知道如何找出每个文件拥有什么样的扩展名,然后区分。如何获取 header 或任何其他方法让我知道什么类型的文件:GIF 或 PNG 或 JPG?
var
MS : TMemoryStream;
GIf: TGIFImage;
jpegimg: TJPEGImage;
begin
MS := TMemoryStream.Create;
GIf := TGIFImage.Create;
jpegimg := TJPEGImage.Create; ///////
try
try
IdHTTP1.get('http://forum.wmonline.com.br/uploads/av-8929.jpg',MS);
Ms.Seek(0,soFromBeginning);
//Gif.LoadFromStream(MS);
//Logo.Picture.Assign(GIF);
jpegimg.LoadFromStream(MS);
Logo.Picture.Assign(jpegimg);
except
ShowMessage('ERRO');
Exit;
end;
finally
FreeAndNil(GIF);
FreeAndNil(MS);
jpegimg.Free; ////
end;