Solved

Storing only one copy of a Picture in dfm file.

Posted on 1997-11-19
6
297 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now