ZLib DEFLATE

Alejandro Tejada capellan2000 at gmail.com
Thu Dec 13 15:20:20 EST 2012


Hi Jan,


Jan Schenkel wrote
> [snip]
> I now need the other way around: a way to inflate data that was deflated.

If you want to decompress data that it's compatible with
the deflate implementation used by Livecode in gzip compress,
then you could "build" a gzip compressed string:

>From the Dictionary's user comments:
http://docs.runrev.com/Function/compress
The compress function returns a gzip compressed string of binary data
structured in the following format:
1) A 10-byte header, containing:
A magic number, composed by two bytes: 1F 8B (Hexadecimal) or 31 139 (ASCII
Numbers of both characters)
A version number (always 08), that specify compression compression method
used in the file. In this case Rev write the byte 08. This single character
correspond to DEFLATE compression.
Additional information like timestamp, optional extra headers, (as the
original file name) are not included and in their place Rev writes six null
bytes: 00 00 00 00 00 00
Last char of 10 byte header correspond to the type of file system on which
compression took place. Rev writes the single byte 03, that correspond to
Unix.
For example: First Ten characters of a gzipped binary string (Hexadecimal)
1F 8B 08 00 00 00 00 00 00 03 (ASCII Characters numbers) 31 139 08 00 00 00
00 00 00 03

2- a body, containing DEFLATE-compressed data

3- Last 8 characters contains a CRC-32 checksum and length of the original
uncompressed data: 
For example: 
Last 8 characters of gzipped binary string (Hexadecimal) 8C 72 E5 F5 1A 34
02 00 
Last four bytes: 1A 34 02 00 = 0002341A = 144,410 represent the file length
(142 k) 
Bytes 8C 72 E5 F5 correspond to CRC-32 of this file: F5E5728C

You could download a stack with a Livecode CRC-32 implementation from:
http://andregarzia.on-rev.com/alejandro/stacks/CRC-32_LiveCode_Script.zip
http://at.livecodejournal.com/stacks/CRC-32_LiveCode_Script.zip

Alejandro




--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/ZLib-DEFLATE-tp4658027p4658087.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list