Roberto Henrique
Roberto Henrique

Reputation: 404

Load image from URL into a TImage

I'm trying to get images from the Internet and present them in my application inside a TImage.

I found a solution that works for URLs with HTTP, but not for HTTPS:

var
  MS : TMemoryStream;
  GIf: TGIFImage;
  IdHTTP1 : tIdHTTP;
begin
  MS := TMemoryStream.Create;
  GIf := TGIFImage.Create;
  IdHTTP1 := tIdHTTP.Create(NIL);
  try
    IdHTTP1.get('http://www.google.com/intl/en_ALL/images/logo.gif',MS);
    Ms.Seek(0,soFromBeginning);
    Gif.LoadFromStream(MS);
    IMAGE1.Picture.Assign(GIF);
  finally
    FreeAndNil(GIF);
    FreeAndNil(MS);
  end;
end;

When trying to get a URL with HTTPS, the following exception is raised:

IOHandler value is not valid

Are there any changes to this solution to make it work with HTTPS?

Upvotes: 0

Views: 323

Answers (0)

Related Questions