| Quote: |
| Read this all in, and then run it through zlib's decompress function. |
| Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote: |
| That's what I did, when ZipLibSharp gave me an error message about missing zlib header.
JPGs and PNGs are not compressed at all in the lvz. |
| Mine GO BOOM wrote: |
| [..]
You need to use whatever is direct access to zlib's compress/decompress functions, not zip wrappers. There is no header info for it. It is a raw compressed stream, the same as .gz files. I've never used C# before, so I can't say. Google says that there are tons of wrappers out there, but for SharpZipLib, it looks like you should be using GZipInputStream for decompression. There is sample code they supply that looks like what you need (gzip, not zip). As for the compression not being there, if you look at the FileTime field, if it is zero, there is no compression. Its weird, but thats how Continuum handles it, so thats how I made DeBuildLevel. You can have anything you want compressed, but the reason it isn't compress is that either the output stream is greater than the input (ie: you can't compress compressed data forever) or the time it would take to decompress the file isn't worth the time so it isn't compressed (ie: jpg/png usually). This is all upto the program that creates the LVZ file, because if you want to put a compressed file that is 1000 times larger the the original file, thats supported. |
| Bak wrote: |
| yeah, when I was making X-LvzToolkit I relized that lots of times the compressed size > uncompressed size, so in that case I leave it uncompressed. Another giveaway that it's uncompressed is if compressed size == uncompressed size (i think continuum looks for this, too).
In either case, if you think it's uncompressed, just output it to a file and see if you can open it in a picture editor. |
Code: Show/Hide After this, if the count is > 0, there should be a compressed header:
4-len str Type - Should be 'CONT' also. If not, the compression header is bad, and do not use. i32 Decompress Size - The size of the data after it would be decompressed. This is the value you should set your out-buffer for the zlib's compression call. i32 File Time - This can either be a file time, if this compressed section is a file, or it could be 0. If 0, then is a special compressed section. The file time is the standard time_t format used by windows/unix. i32 Compressed Size - The size of the compressed data in the .lvz. This is how many bytes you'll need to read to get your required data. Null-end str File Name - This string is always null ended. If no file time, the File Name should be blank (just the 0x00), but do not always count on it. * data * Compressed data - This should be the length of the Compressed size. Read this all in, and then run it through zlib's decompress function. ... The decompressed data can be 1 of two types for the current .lvz format. The first type is more often found in .lvzs, and this is the file type. Files are determined by having a File Time not equal to 0, and having a File Name length not being 0. Please be warned, future formats of .lvz's may change one or the other of these checks, so a good safety feature would be that files require both of these to be true. Files are normally just saved to the proper folder and the correct file time set to it. If you do not know how to set file times, its is not 100% important for most DeBuildLevel like programs. The only other current decompressed data type is the Object section. The object section is determined by having a File Time equal to 0 and the File Name length being 0. |