[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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?
0
strang
Asked:
strang
1 Solution
 
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
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
 
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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now