April 29, 2024, 04:21:11 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


ZLIB package for Aurora

Started by Ionic Wind Support Team, October 14, 2006, 12:21:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

I recently needed an in-memory compression utility for a project I am working on.  zLib fit the bill and is very easy to use. 

Attached to this message is the distribution for Aurora complete with converted include file, Aurora import library and the latest release of the zlib DLL.  Installation instructions can be found in the archive. See  "usage.txt"

Quote from the zlib site http://www.zlib.net

Quote
zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms. Unlike the LZW compression method used in Unix compress(1) and in the GIF image format, the compression method currently used in zlib essentially never expands the data. (LZW can double or triple the file size in extreme cases.) zlib's memory footprint is also independent of the input data and can be reduced, if necessary, at some cost in compression. A more precise, technical discussion of both points is available on another page.

And here is a quickie test program to make sure you've installed the files correctly. The example compresses itself so name the source file "zlib_test.src"


#include "zlib.inc"
sub main()
{
unsigned int file;
print(zlibVersion());
file = openfile(GetStartPath() + "zlib_test.src",MODE_READ);
if(file)
{
//compress
uint srclen = GetFileLength(file);
uint destlen = compressBound(srclen);
byte *buffer = new(byte,srclen);
byte *buffer2 = new(byte,destlen);
Read(file,buffer,srclen);
if(compress(buffer2,&destlen,buffer,srclen) == Z_OK)
print("Original size: ",srclen," Compressed size:",destlen)
else
print("Error compressing buffer");
CloseFile(file);
//uncompress
if(uncompress(buffer,&srclen,buffer2,destlen) == Z_OK)
print("Uncompress Success!, Size: ",srclen)
else
print("Error uncompressing buffer");
delete buffer;
delete buffer2;
}
while GetKey() == "";
}


Ionic Wind Support Team

Todd Riggins

Coolness! This should help out in handling pak files. Thanks  ;D
Brought to you buy: http://www.exodev.com