Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

high memory use - images 1

Status
Not open for further replies.

matematik

Programmer
Aug 13, 2007
8
SI
I'm building an application, which has got 30 images(TImage) in one form. This pictures size is about 800 KB. The problem is, that program use a lot of memory(300 MB), I would understand if it would use about 50 MB of ram, because without pictures, it uses about 20 MB. What's the problem?
 
Well if these are JPG or PNG (or quite a few others actually), then the images are stored in files in a compressed format. The amount of file space used has little to do with how much memory is needed when the image is expanded out.

You'd get a much better idea of how much memory is needed from looking at the header information for the file telling you the dimensions of the image.

Figure either 3 or 4 bytes per pixel, so a 1024x768 image would be just over 2MB at 3 bytes per pixel, and 3MB at 4 bytes per pixel.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Well, now i know why it uses so much memory. Can I show this pictures, without storing them in memory?
 
Create thumbnail images out of them, and display them instead perhaps?

You're not going to tile 30 images, each 1024x768 say on screen at the same time and be able to see any amount of detail in any of the images.

When the user selects an image, then you load that one at full size.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Ok, i'll try this. Does anyone has a code to resize image from disk and than show it in TImage, without saving it to disk?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top