开发者

How to embedded images to EXE file and show them as slideshow

I have a requirement to build an Image manager which will allow users to build a collection of photos/images and then give them an option to convert these photos to a single EXE which when run, will show the photos/images on ta开发者_高级运维rget PC as a slide show in full screen.

Is it possible to do this for multiple images?


Should be possible. What you'll have to do is a EXE framework (stub) that reads its own binary and checks for an appended image list (can be something simple like [number of images][image sizes][image_1]...[image_n]) and displays those in a slide show.

You can then concatenate the EXE stub, the image information and the images for your final slide show EXE.

Searching for the end of the EXE file (beginning of the image list) is usually done by using a constant header that does not appear in the EXE file, knowing the size of the stub EXE or writing the image list offset at the end of the EXE file. Alternatively, you can store the information the other way round and start reading from the end of the file.

Here is something that looks like a good link for stub example code.


IrfanView can allready do that:
http://www.irfanview.com/
It can even unpack them from the exe-file again.


You can build an application that enumerates its' own resources and loads them for display; this one the end users will run for the slide show. A separate app could add the user-selected resources to the first one. See the MSDN documentation for UpdateResource for info on adding the resources, and EnumResourceNames for information on enumerating them.


We provided some free and open source classes to read a .zip archive bundled (or not) to an exe. You can therefore append any .zip archive to your exe, then extract any picture inside this .zip with one class.

Use the following method:

constructor TZipRead.Create(const aFileName: TFileName; ZipStartOffset, Size: cardinal);

and provide paramstr(0) - i.e. your exe - as aFileName and ZipStartOffset as a minimal original exe size: it will search for the beginning of the .zip file from this offset. Leave Size parameter as 0: it will get the size from the file size itself.

The same class can get any .zip archive embedded as a resource to your exe, if you prefer.

They are two ways of appending .zip content to an exe:

  1. use copy /b original.exe+pictures.zip newembedded.exe
  2. use the TZipWrite class provided, and its AddFromZip() method to create your exe from Delphi code: you can even compress and append your images on the fly, with no temporary pictures.zip file.

See http://synopse.info/forum/viewtopic.php?pid=163

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜