Is it possible to check when an image has been uploaded within a TImage
?
For example: I have a label that appears "Loading Image ..." when TImage
loads any image, that label should disappear. Is it possible?
Is it possible to check when an image has been uploaded within a TImage
?
For example: I have a label that appears "Loading Image ..." when TImage
loads any image, that label should disappear. Is it possible?
Yes. Assuming the image you are uploading is from the internet, you can do so:
Var
imageURL: string;
MS: TMemoryStream;
Jpg: TJPEGImage;
begin
imageURL := 'URL da imagem aqui';
try
MS := TMemoryStream.Create;
IdHTTP1.Get(imageURL, MS);
if ms.Size > 0 then begin
Jpg := TJPEGImage.Create;
MS.Position := 0;
try
Jpg.LoadFromStream(MS);
Image1.Picture.Assign(Jpg);
finally
Jpg.Free;
end;
end;
finally
MS.Free;
end;
In event OnProgress()
of component TImage
do so:
procedure TForm1.Image1Progress(Sender: TObject; Stage: TProgressStage;
PercentDone: Byte; RedrawNow: Boolean; const R: TRect; const Msg: string);
begin
if PercentDone = 100 then
Label1.Caption := 'imagem carregada!';
end;