There are many small files (country flags). they are loaded into TImage as needed. It is required to create one of all these files, so much so that one could get one picture from it and load it into a TImage without extracting all the files to disk.

I searched on Google ... but I just don’t know how to ask him ... I didn’t ask about it - it gives me information about how to compile resources to the file, or about packing and then extracting files to a disk ...

In general, what would be how modern, say, games work ... in which resources are packed into large files

  • one
    How about approaching the question from the other side and using TImageList? - karmadro4
  • No, it will not work. I need to periodically update this large file via the Internet - Vladyslav Matviienko
  • Take the source of the old unix utility ar and see (tar is its successor). Perhaps in the one that is used now, there are a lot of bells and whistles, so find the old one (just don’t forget about Windows with text / binary input / output modes). In general, OS / 360 and heirs even had a special method of accessing library files. Their functionality here is redundant (no update required). - alexlz
  • I do not see how one prevents the other, but oh well ... Then one big file + table offsets. - karmadro4
  • one
    > compiling resources to the executable There is also a compilation of resources into an external library. - insolor

2 answers 2

There is a simpler version - collect all the flags in one file.

Load in TBitmap, for example, using LoadFromFile.

And then using CopyRect, copy to a TImage.

  • one
    Actually, it does image list - karmadro4
  • but this is interesting! I already wrote why TImageList is not suitable. - Vladyslav Matviienko
  • one
    @metalurgus, justify. I do not see how the update of all flags via the Internet breaks the logic provided by the image list or the homemade bike offered in the answer. - karmadro4
  • Googled to TImageList. And I found an article that describes how to save resources from a component (TImageList) to a file, and vice versa. I will try - Vladyslav Matviienko
  • one
    1 question how to merge The easiest way to fill all files in TImageList and then click in the editor TImageList-a button Export. And you will get 1 file in which all the flags are beautifully next to each other. 2 question how to use it The options heap all of the above will fit both the LoadFromFile in TBitmap and one large file + offset table. Vobshem what like. - Vahan Av

You just need to create an archive. The easiest way is to find a regular zip archiver (or 7z) and pack resources. It is not strange, but this is what a large number of game manufacturers do. Components can be searched on

Method two. Create such an archive yourself. The simplest option is to write down 4 bytes marker, then 2 bytes the length of the name, then the name itself, then 4 bytes the data size (picture). And read it all through TFileStream. TImage / TJpeg can load themselves from a stream (stream) and at the same time deduct as much as they need.

If you need to find a resource by name, you get the following algorithm: - read the marker - read the length of the name, subtract it - read the size - if it is a suitable name - just read the picture - if not, then do seek for a known number of bytes and repeat the procedure

  • For Delphi there is a good free library for working with archives of different formats - Abbrevia . - Nofate