I want to download images from a server, load them into TImageEnMView, and then use CopyToIEBitmap to view and edit them in TImageEnView.
To speed up the process, I download the image stream from the server to the local machine and then load it into TImageEnMView using LoadFromFileOnDemand. My question is: When can I safely delete the locally downloaded image files without affecting the use of the CopyToIEBitmap method?
Here is my code:
while not rs.eof do
begin
PhotoStream := TBytesStream.Create;
vImageName := rs.fieldbyname('imagename').ToString;
try
if RequestStream('get', 'test03', vImageName, vMsg, PhotoStream) then
begin
PhotoStream.Position := 0;
PhotoStream.SaveToFile(vImageName);
ImageEnMView.LoadFromFileOnDemand(vImageName, True);
TFile.Delete(vImageName); // When to delete it?
end;
finally
PhotoStream.Free;
end;
rs.next;
end;