I declared a TImage object in the IDE.
The program displays several images on that object using multiple image.picture.loadfromfile .
The first image display is as expected. However, the program hangs on a following display, sometimes on nr. 3, or on nr. 4. The program freezes for about 30 seconds, then shows a heap error (error 203) when in IDE mode. It shows an Out of Memory when run directly from the .exe .
The directory is small (some 30 files).
What can I do?
Below the simplified code. The filenames in a directory are copied to a stringlist; then the image files are displayed one by one.
MyFileList.Clear;
if FindFirst (MyDir + '\' + '*.*', faAnyFile, sr) = 0 then begin
MyFileList.Add(sr.Name);
while FindNext(sr) = 0 do
MyFileList.Add(sr.Name);
FindClose(sr);
for i := 0 to 11 do begin
try
MyImage.Picture.LoadFromFile(MyDir + '\' + MyFileList);
except
on E: Exception do
showmessage('This is not an image file');
end;
showmessage('Continue with the next one');
end;
end;
Using Lazarus 1.4.4 with FPC 2.6.4. Windows7.