How can I store many images in one file for a WinForms application?

I have a .net WinForms 2.0 application that currently has an image library of 3000 images. I am currently using SQLite and store all images as BLOBs with unique IDs that make it easier to find.

The advantage of this is that end users don't have to worry about the installer unpacking a massive frame of images on their computer, and when updates are made, I can pull one file for users to download, a fresh copy of everything. The files tend to be quite large (currently ~ 60 megabytes), but end users are used to them, and the app also has a "no picture" mode for those dialing.

The only downside to all of this is that generating the library can be a little tricky at times. The data needs to be converted to binary, I need to make sure the corresponding ids are linked correctly. The job that generates the library takes time to run.

I am in the process of updating an application and I am wondering if there is a better way to do this. I would still like to simplify a single file-based approach for sending updates to users and reducing the size of the desktop space. Is there some kind of "portable filesystem" or resource library I can use / build that will allow me to easily insert / retrieve images from it without having to have a database for the application to interact with?

+1


a source to share


4 answers


Resx file (compiled to resource dll)? Or more simply - a zip file? #ZipLib can be used.



+3


a source


7zip also has a library that you can also use, see this

Also you can move images that need to be served from the web server and use the client cache locally and then periodically check the client file for an updated image, so only the required images need to be downloaded.



You may also have versions for remote access users.

0


a source


I've used ImageList and AddStrip control methods in situations like this. Then I have one giant PNG file containing all the images. This works great for icons, but won't work well for other resource types.

0


a source


Depending on your circumstances, a custom ISAM file is an option.

General file layout:

----------------
| Count | int |
----------------
| Index |
----------
| Images |
----------

Index format

----------------
| offset | int |
----------------
| size | int |
---------------------------
| description | char (50) |
---------------------------
| id | int |
----------------

The score will be an integer containing the number of images in the file. The index will contain pairs (offset, size) describing the offset in the file to search for, and the number of bytes read starting at that offset.

The disadvantage of this format is that the file will need to be re-created to replace the existing image.

Fixed length metadata such as descriptions and ID can be placed in the title.

(Perhaps one of the main benefits of this method of insanity is access speed if you keep the pointer in RAM.)

0


a source







All Articles