0
votes

I am trying to load an image from a URL in Delphi 2010.

I'm pretty new to Delphi and found this code but keep getting:

undeclared identifier at idhttp1.get

Do I need to add something to the uses? Thanks

uses
  GIFImg;

procedure TForm1.btn1Click(Sender: TObject);
var
  MS : TMemoryStream;
  GIf: TGIFImage;
begin
  MS := TMemoryStream.Create;
  GIf := TGIFImage.Create;
  try
    IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
    Ms.Seek(0,soFromBeginning);       
    Gif.LoadFromStream(MS);
    img1.Picture.Assign(GIF);

  finally
    FreeAndNil(GIF);
    FreeAndNil(MS);
  end;
end;
1

1 Answers

2
votes

The usage suggests that IdHTTP1 is a component of type TIdHTTP that is placed on the design surface of your form. Likely that is the step that you have missed. Once you perform that step the code should compile.