showing images & free them

I use a Timage component to show many pictures one by one. I use 'Timage.loadfromfile()' to load a picture,and I use it again when I need to show an other picture.but after I show some pictures,the Application abort.I think that's maybe because I'm not free the memory?? How can I free the memory? or there has any other reason?
strangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
Please tell us more about how your application aborts. Some error messages?
And please give us some code as well. How does code "around" your LoadFromFile call look like?
0
simonetCommented:
Are you creating any object on runtime?

Alex
0
EpsylonCommented:
I guess you mean Image.Picture.LoadFromFile.
Try the following before loading a new picture:

Image.Picture.Bitmap.FreeImage;
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

wipnavCommented:
My answer is that the Image.Picture.LoadFromFile method works properly. You should be able to load as many different pictures as you like without the need to ever free the memory. I wrote a sample application in D3 that contained a loop. Within the loop I loaded two different .bmp images into a TImage component. I then used Memory Sleuth to monitor the application. After 1000 itterations there were no memory leaks, and no problems. My answer is that your problem must be something else that you are doing in your program.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EpsylonCommented:
What about 100 diffent images of different sizes? I think the problem is memory fragmentation. With only 2 pictures that won't happen very quickly.
0
strangAuthor Commented:

the error message:
1.'stream write error'
2.'Access violation at adress xxxxxxxx.Write of adress  xxxxxxx'
3.'Canvas does not allow drawing'
the application showing one of these three message,then can't show any image at all.

in my program,I use TQrimage to load picture and use Tqrpreview to show them.I can show several pictures once and change page through setting Tqrreview.pagenumber .
0
EpsylonCommented:
Why are you using TQrimage and Tqrpreview? This puzzles me completely. These components are not quite bugfree.

Why not use TImageList.
TImageList.Add(...) to add Bitmaps
TImage.Picture.Assign(Bitmap) to show one of the pictures.
0
EpsylonCommented:
Hmmm forget TImageList. It only accepts images with the same size. Using TList instead would be better.
0
wipnavCommented:
I read the original question as a problem with the TImage component. I have never used TQrimage or Tqrpreview, and I don't think I want to.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.