Storing only one copy of a Picture in dfm file.

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

Are you using Delphi 2 or 3?

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.


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
sassas081597Author Commented:
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.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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.

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.

sassas081597Author Commented:
Thanks, all. The answers were quite good. Special thanks to JimBob. The dll becomes quite speedy and takes less place. Thanks for qiuck answer
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.