Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way of sharing images between several applications

Tags:

delphi

I'm working on a project which is composed of several compiled Delphi applications (over 20 exe's and dll's) and I'll be needing to share 60+ images (16x16, 24x24, 32x32, ...) between all of them.

I've though on two different ways of sharing images between all the applications, but I'm not sure which is better:


Idea 1:

Create a resource-only DLL project, which contains a resource link reference to the .res file that contains all my images. Each application will in turn load the dll and read the necessary images it may need into either a TImageList or TImage depending on it's needs.

Pros: Allows to keep the images in the repository in their native format.

Cons: I won't be able see the images at design time as they will only be loaded at run time. I'll also have to create the same number of constants as there are images or use a set with the same number of values as there are images so that each image can be referenced independently of it's name on the resource file.


Idea 2:

Create a Data Module which is compiled as a bpl and included as a run-time package on all the applications. I would add the images to several TImageList's (depending on the image size) or into a TPngImageList (which allows images of several sizes on a single component).

Pros: I'll be able to add this Data Module to all the applications I need and see at design-time all the images I may need to use.

Cons: All the images will be loaded into memory even if I only need to use one. I need to make sure the order of the images is never changed when adding/modifying images into the TImageList/TPngImageList. All images will be stored in a single .dfm.


Idea 3: (New)

After looking at other applications who also need to share images between compiled exe's, I've had yet another idea. Save all the shared images as plain png/ico files on a sub-folder where the compiled files are (Data for example).

Pros: No need to load all images in memory, I can just get the ones needed. This may be specially important if the total number of the images is rather large (one application which uses this method has 1400 images on a Data sub-folder).

Cons: Images will be visible/available to anyone. May use up a little more disk space on the user machine.


I would like to ask for comments on these two ideas or any other suggestions on how to better accomplish this.

Thanks!

like image 321
smartins Avatar asked Aug 29 '11 15:08

smartins


People also ask

What is the best way to share photos with a large group?

Google Drive/Google Photos Google Drive and Google Photos are well-known for file sharing and photo organization, respectively. Just about everybody is familiar with the Google suite and its applications. And you can use both Drive or Photos to gather photos from a group.

How can I easily share a lot of photos?

One of the most popular methods for sharing large amounts of photos online is by using a file-sharing site. Sites like HighTail (formally YouSendIt), Wikisend and Streamfile let you sign up and upload your photos, where they'll be stored in a downloadable zip file.


1 Answers

I have a strong preference for option 1. Doing it this way allows you to keep the images in your revision control repository in their native format. With option 2 you store images in .dfm files which I find exceedingly unsatisfactory. The downside is that you lose design time viewing of the images. I personally prefer to make that trade-off.

In my software I have a single global image list which I populate at runtime by loading from resources, and of course also assign image indices at runtime. The other benefit that this brings is the ability to choose image sizes appropriate to font scaling. Otherwise you need to have separate image lists for 16px icons, 20px icons, 24px icons, 32px icons etc.

like image 191
David Heffernan Avatar answered Sep 23 '22 06:09

David Heffernan