Article View: borland.public.cppbuilder.nativeapi
Article #16994Re: File Storage
From: user
Date: Sun, 13 Apr 2003 13:08
Date: Sun, 13 Apr 2003 13:08
30 lines
2669 bytes
2669 bytes
Lapo wrote: > I would like to store some images (320x240 in JPEG format) in a file; When > the file size will be over than 20MB, new images will overwrite the oldest > ones. > The problem i found is that JPEG images are not all the same size, so > sometimes a new image can overwrite more than 1 old image. > I read something about circular storage, but I'm not able to solve it. > Any tips? It's compression that accounts for the same size images having different file sizes. To store each image in the same sized section of a file will require assuming each image might take the largest possible amount of space. It might be possible to store the images uncompressed to be certain they are the same size, but both of those approaches seem wasteful of disk space. One way this kind of thing is done is to store a "directory" in the file along with the data. This directory would contain the number of images and their offset in the file, but could also store the image names and so on. To use such files, functions to update the directory whenever an image is added or removed will be needed, as well as functions that can read the directory and use it to locate the images in the file. To replace an image, each image except the one that is to be deleted may be copied to a temporary file, then the new image added. Finally the original file will be deleted and the temporary one renamed. This, by the way, is pretty much how zip files work. Since there already exist libraries to manipulate those files, you might consider using one of them to save yourself some coding. Other archive formats and libraries are available as well.
Technical Details
Message-ID:
<3E996140.9070000@domain.invalid>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e9939ba@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,fd9e372a672203ff X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-13 06:19:21 PST Message-ID: <3E996140.9070000@domain.invalid> Date: Sun, 13 Apr 2003 09:08:16 -0400 From: user@domain.invalid User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: File Storage References: <3e9939ba@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 151.201.18.183 X-Trace: newsgroups.borland.com 1050239315 151.201.18.183 (13 Apr 2003 06:08:35 -0700) Lines: 31 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail