views:

128

answers:

4

I have a .net WinForms 2.0 application that has an image library of about 3000 images currently. Currently I'm using SQLite and storing all of the images as BLOBs with a unique Ids that makes things easy to retrieve.

The benefit to this is that the end users don't have to worry about the installer unzipping a massive blob of images on their computer, and when updates are made, I can push out a single file for the users download that is a fresh copy of everything. The files to tend to be rather large (currently ~60 meg.), but the end users are used to it and the application also has a "no image" mode for those on dial-up.

The one downside to all of this is that generating the library can be a little tricky at times. The data has to get converted into the binary format, I have to make sure the corresponding Ids are properly linked. The job that generates the library takes a while to run as well.

I'm in the process of upgrading the application and I'm wondering if there is a better approach to doing this. I'd still like to keep the single file approach for ease in sending updates to users and keeping the footprint on the computer smaller. Is there some kind of "portable filesystem" or resource library that I can use/create that would allow me to easily insert/retrieve images from it without necessarily having a database for the application to interact with?

+3  A: 

A resx file (compiled to a resource dll)? Or simpler - a zip file? Perhaps using #ZipLib.

Marc Gravell
If I used a zip file, would I be able to selectively pull out an image file without having to uncompress the entire archive?
Dillie-O
Yes, you can extract only what you need.
Joel Lucsy
Yes - a zip archive essentially has a file header table, allowing you to extract files individually - or at least, skipping those you don't want. The #ziplib samples show all or some of this - it isn't very tricky.
Marc Gravell
Do you know what the benefits of the resx over the zip file would be? I'm still weighing the differences.
Dillie-O
Well, you can maintain it in VS, and internationalize it fairly easily - but I wonder if the zip (as the simpler option) wouldn't be easier to implement. In particular, it is easier to edit zip contents.
Marc Gravell
A: 

7zip also have a library you could use also, see this

Also you could move the images to be served off a web server and have the client cache the image locally, and then have a way of the client checking for an updated image periodically, that way only the required images would have to be downloaded.

You could also have lo-res versions for dial-up users.

benPearce
A: 

I've used the ImageList control and AddStrip methods in similar situations. I then have one giant PNG file that contains all the images. This is great for icons but won't work well for other types of resources.

Paul Alexander
A: 

Depending on your circumstances, a custom ISAM type file is a possibility.

The overall file layout would be:

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

Index format

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

The count would be an integer containing the number of images in the file. The index would contain (offset, size) pairs describing the offset into the file to seek to and the number of bytes to read beginning at that offset.

A downside to this format is that replacing an existing picture would require rebuilding the file.

Fixed length metadata like descriptions and ID's could be placed in the header.

(Perhaps one upside to this method of madness is the speed of access if you are holding the index in RAM.)