How to decompress a file using zlib?

I was meaning to decompress a file, but I just don’t really understand the zlib api, and the zlib manual isn’t helping much…

I’m trying to create a loader for .xp files from an ascii drawing app called REXPaint. I know the file I want to decompress is compressed using gzip, according to the documentation:

The .xp files are deflated with zlib (specifically they are gzipped files created via gzofstream);

Can someone explain to me how to use zlib for this?

I’ll give it a shot if you can provide an .xp file to work with. I looked at the REXPaint site and could not find any .xp files to download.

The .xp files are REXPaint images, that you create and draw in it.

I got some help on discord and managed to do it with core:compress/gzip. I’ll post it here in case anyone ever needs something like this.

import "core:bytes"
import "core:compress/gzip"

// ... 

data: bytes.Buffer
gzip.load_from_file(filepath, &data)

It works pretty well for my use case.

Thanks anyway.

1 Like