Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Lapo
Sun, 13 Apr 2003 10:21
File Storage
Author: Lapo
Date: Sun, 13 Apr 2003 10:21
Date: Sun, 13 Apr 2003 10:21
13 lines
1383 bytes
1383 bytes
Hi all, I would ask some help in a problem i meet... 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? Lapo PS. I hope that my english is clear... I'm sorry for my english
Re: File Storage
Author: 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.
Re: File Storage
Author: Michael Kelly
Date: Sun, 13 Apr 2003 16:33
Date: Sun, 13 Apr 2003 16:33
29 lines
1696 bytes
1696 bytes
On Sun, 13 Apr 2003 12:21:52 +0200, "Lapo" <lapoguidi@inwind.it> wrote:
>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?
You might try going on some of the open source
sites and looking at file indexing code. There must
be some small databases or indexing algorithms
around. Maybe some of the computer magazine
sites would have articles that would be helpful
too.
Try sites like
www.sourceforge.net
www.ddj.com
www.wd-mag.com
www.cuj.com
or just search google for
indexing algorithms written
in C/C++.
--
"I don't want to belong to any club that would have me as a member."
-- Groucho Marx
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads