Solved

Storing only one copy of a Picture in dfm file.

Posted on 1997-11-19
6
308 Views
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?
0
Comment
Question by:sassas081597
  • 2
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350929
Are you using Delphi 2 or 3?

0
 

Accepted Solution

by:
kimfriis earned 50 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.

0
 
LVL 1

Author Comment

by:sassas081597
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.
Thanks,
SASSAS
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Expert Comment

by:kimfriis
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.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1350933
Hi

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.

JB
0
 
LVL 1

Author Comment

by:sassas081597
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
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 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