I have a custom data file from a project that was authored in actionscript some years ago by another developer. I am porting parts of the project over to Unity 3D. I don't have any documentation for the original project (I hope to speak to the original developers at some point but I cannot wait for that).

The file is a special bitmap that represents the positions of objects on a grid. The custom file is created using an editor created in Adobe air. I believe (not knowing any better) that the source code I have for the file decoder is the same source from the editor. I don't have the editor source code.

Where I am getting into trouble is the binary file. From what I can tell at the moment, the file is a compressed byte array on the Adobe air side of things. I don't believe I can just load the compressed file with Unity3D as a resource object. I would like to decompress the file and use it as an asset in Unity.

I am trying to figure how to decompress the binary file. I have tried viewing the file contents in a hex editor to establish what the compression format is with no joy; I have not done anything specifically like this before 😊. I have tried to use gzip and a few other apps to decompress the file.

Form what I have read in the action script documentation that the default compression should be zlib.

Here is some edited code from the original project for decoding the bitmap:

import flash.utils.ByteArray; public function decode(byteArray:ByteArray):Boolean { var i:uint; var j:uint; if(colourMap!=null) { colourMap.dispose(); depthMap.dispose(); } byteArray.uncompress(); byteArray.position=0; var fileVersion:String=byteArray.readUTFBytes(FILE_VERSION.length); if(fileVersion==FILE_VERSION) { numWidth=byteArray.readUnsignedInt(); numHeight=byteArray.readUnsignedInt(); if(numWidth==0) { numWidth=30; trace("WARNING FOR SOME REASON WIDTH WAS 0 FROM FILE"); } if(numHeight==0) { numHeight=30; trace("WARNING FOR SOME REASON HEIGHT WAS 0 FROM FILE"); }

Here is a hex dump of the initial part of the binary data file:

78 da ec bd 55 cf 6c 5d 76 a5 79 7c 53 2a ff 8c

  • \$\begingroup\$ I realize now I was getting things mixed up. A compressed data stream is not the same as a compressed archive. The data file does not have any header information to indicate what the contents are as it just a stream of bytes. I will report back... \$\endgroup\$
    – M. Bedi
    Jan 20, 2016 at 23:10

1 Answer 1


I am able to de-compress the data file using an answer from here:


The printf is creating a gzip header to coax gzip into decompressing the byte stream.

printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - somedata.raw |gzip -dc

Where "somedata.raw" is the compressed byte stream.

To save the uncompressed data to a new file I changed the above to:

printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - somedata.raw |gzip -dc > uncompressed_data.raw

I viewed a hex dump of the head of the new file & it was what I expecting.

0000000 42 37 31 2d 30 2e 32 00 00 00 31 00 00 00 21 01

The first 3 characters are B71 which what I am expecting it relates to the a version number in the data file.

Heh heh, it has been years since I had to think about ASCII code.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .