Storing only one copy of a Picture in dfm file.

Posted on 1997-11-19
Medium Priority
Last Modified: 2010-04-04
I have 10 TImage components on a form in a DLL, containing the same picture. I wish to store only 1 copy of THIS picture in this DLL. For some reasons I should not create a new class.  
However, in a case, when I put 10 TImage and load this picture in them, my DLL becomes too large (it contains 10 copies of the same picture as Picture.Data property of every Image). What can I do to reduce the DLL size in this case?
Question by:sassas081597
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2

Expert Comment

ID: 1350929
Are you using Delphi 2 or 3?


Accepted Solution

kimfriis earned 150 total points
ID: 1350930
What you could do is to put the image in one of the TImages, and then on load time (on the DLL side) copy the image to the other images? I expect that that is the desired effect.


Author Comment

ID: 1350931
You are right, however I'd like to understand the way, Delphi stores the Picture data.  In your case my form loads too long. It's no problem - you really answered my question - however I'd like to view this problem deeper. If you can give me a more deeper comment - I accept your answer.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 1350932
I am not sure if this is the comments that you are looking for? But the way Delphi stores the Image data is that when you design your form, it stores the whole form in the DFM file. Try right-clicking the form and choose [view as text]. The DFM file is like a .RES I think, because it just links the .DFM file into the program when you compile (have you seen the {include *.dfm}).
Now the way that the components save its data to the .DFM file is via a stream. So each component stores there own data in the .DFM file, and that is why it fills so much.

Expert Comment

ID: 1350933

Just a small comment...  kimfriis is right - the dfm is stored as a resource in the exe file.  The binary bitmap data is stored in this resource, and if the bitmap data is large the form will take a long time to load.

You could try to store the bitmap as a Bitmap resource (instead of part of the DFM resource) and then load the bitmap from the resource at run-time.  This is quite easy if you use a TImageList (which is why I originally asked if you are using Delphi 2 or 3, because Delphi 1 doesn't have a TImageList):
MyImgList.ResourceLoad(hInstance, rtBitmap, 'BMP_MYBITMAP', clSilver);

You can then use the image list to get the bitmap, and put it into your images.

I have found that for large images, this can speed up the opening of the form simply because the position that the bitmap is stored in the exe has changed from the DFM section to the bitmaps section.


Author Comment

ID: 1350934
Thanks, all. The answers were quite good. Special thanks to JimBob. The dll becomes quite speedy and takes less place. Thanks for qiuck answer

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question