Decompressing Bytes with GZip

I’m pretty sure there was, at some point, a method in which you could decompress Bytes loaded from a file using the GZIP compression method but I cannot seem to find an example of that.

Is there an example where this can be done, or will I need to extern a GZIP library for the target language?


Here is an example of what I’ve tried so far:

var fontsPath = "data/fonts.dat";
var fontsFile = File.getBytes(fontsPath);
var fontsData = ByteArray.fromBytes(fontsFile);
var count = fontsData.readInt();

I think, however, the way OpenFL’s implementation works is that it assumes the file is an ordinary ZIP, which it isn’t.

I’m getting the error: ZLib Error: Incorrect header check (-3) when launching the application.

Okay, so I just found the format library which actually contained exactly what I needed. So, don’t need any code examples after all :slight_smile:

Are your files compressed with headers?

If not, try DEFLATE instead of ZLIB. What version are you using?

Oh, and if it is GZIP, perhaps this would work better:

It should use native C++, so I bet it’s a lot faster than format

Either one works just fine, so it really doesn’t matter which one I use. It works, that’s the main thing :slight_smile:

That being said, since lime does have native capabilities, I may use that over format.