1

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?

Dillie-O
  • 29,277
  • 14
  • 101
  • 140
  • What are the images? User data or application resources? Why can they not be deployed as a folder of images on the harddrive, or even as an optional addin installer? – Neil Barnwell May 05 '09 at 22:40
  • Application resources. A user pulls up details on a card from the master database, and the corresponding image is pulled from the other image. I'd like to avoid having a folder of images if it can be helped to keep the overall file count of the application minimized. Previously there were some concerns over the abuse of the images themselves (long story), so having them protected in that sense was also addressed. – Dillie-O May 05 '09 at 22:48
  • No matter what method you use, you're not going to prevent users from (ab)using the images. That's the one lesson DRM has taught us. If your main concern is minimizing proliferation of files, a ZIP file is a good solution. – Matthew Flaschen May 05 '09 at 23:47
  • Yeah, that's where I'm at. I know abuse has been done in the past, but it is more the "due diligence" play and more importantly, not exploding 3000+ files onto the user's machine if I can't help it. – Dillie-O May 05 '09 at 23:56

4 Answers4

3

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

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • 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 May 05 '09 at 22:45
  • Yes, you can extract only what you need. – Joel Lucsy May 05 '09 at 22:47
  • 1
    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 May 05 '09 at 22:56
  • Do you know what the benefits of the resx over the zip file would be? I'm still weighing the differences. – Dillie-O May 06 '09 at 15:18
  • 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 May 06 '09 at 15:21
0

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.

Community
  • 1
  • 1
benPearce
  • 37,735
  • 14
  • 62
  • 96
0

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
  • 31,970
  • 14
  • 96
  • 151
0

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.)

user79755
  • 2,623
  • 5
  • 30
  • 36