I'm trying to open an image that is on my site, I can not use TWebBeowser because it has a vertical ScrollBar that can not be removed, so I only have Timage left.
I'm trying to open an image that is on my site, I can not use TWebBeowser because it has a vertical ScrollBar that can not be removed, so I only have Timage left.
You can use the IdHTTP component for this. Create a new project, throw an IdHTTP component and another IdAntiFreeze in the form, also a TImage and a TButton. Then add the following code in the Button's OnClick event:
var
Jpeg: TJpegImage;
Strm: TMemoryStream;
begin
Screen.Cursor := crHourGlass;
Jpeg := TJpegImage.Create;
Strm := TMemoryStream.Create;
try
IdHttp.Get('http://www.site.com.br/imagem.jpg', Strm);
if (Strm.Size > 0) then
begin
Strm.Position := 0;
Jpeg.LoadFromStream(Strm);
Image1.Picture.Assign(Jpeg);
end;
finally
Strm.Free;
Jpeg.Free;
Screen.Cursor := crDefault;
end;
If the image is very heavy, I recommend that you play this procedure inside a thread.
I hope I have helped!