Solved

Storing only one copy of a Picture in dfm file.

Posted on 1997-11-19
6
318 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
[X]
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
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
Technology Partners: 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!

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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