Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

images pack file

Status
Not open for further replies.

jigolo

Programmer
Jan 6, 2004
20
CA
How can I create a file containing load of images on disk (like a .zip), then access the image I want in a c# app?
 
Create a structure to hold the name of a file, the size, the offset into the file, and the offset to the next structure.

Open the file for writing. Write one structure. Write the bytes of your first image/file/whatever. Reposition the file pointer back to the start of the structure, and re-write the structure with the new info.

Reposition the file pointer to the end of the file (using the offset to the next structure value you wrote in the first structure).

Write the 2nd structure. Write the bytes for the 2nd data file. Reposition the file pointer to the start of the 2nd structure. Rewrite the 2nd structure using the new values.

For the last data file, put a zero value in for the offset to the next structure to indicate it's the last file in the archive.

You can also get fancy by storing a MD-5 hash of the datafile to detect any file corruption, etc. You can also have it span media by putting a flag in the structure to indicate there is more to the file than is in the remainder of the file.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top