Michael Lam
asked on
how to convert .bin file to .tmx (Tiled Map Editor) file
i am trying to do some reverse engineering here to reuse/modify some good existing map files in my game that are in the .bin format. normally, you used Tiled with QT plugin to export a visual map (.tmx) file to a .bin file. i was able to further convert the .bin file to a text file by converting the byte array into a HEX string, which i can display as a text file. this way i can find out how the map actually works.
so what's in the .tmx file as:
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAC+3YsQmAQBAAQb EDsQf7L1HN xECDBUWZgc uP5fjghwEA eNr89gIfp1 +jX6Nfo1+j X6Nfo1+jX6 NfM20zXszy 3mq/sPfVsN Gw07A7vpVa Nu6x07DTsN Ow07DTsNOw 07A7/0vo2b jJ7u6v7Iuz Ajr0Cq0AKA AA
</data>
now becomes the following HEX string:
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFF FFFF
12121212121212121212121212 FFFF121212 1212
to do the reverse engineeing, i do the following:
1) convert the HEX string back to byte array
2) do gzip compression using the following method:
public static String gzipCompress(String str) throws IOException
{
if (str == null || str.length() == 0)
{
return str;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes()) ;
gzip.close();
return out.toString("UTF-8");
}
3) do base64 encoding using:
Base64 base = new Base64();
byte[] dataBytes = base.encode(data.getBytes( ));
but the resulting string looks a little bit different:
H4sIAAAAAAAAAPv/fxQMZyA0at 6oeaPm4QQC jBCgSm1zR6 A/o6E4auAw NXBIlBCMZA AAqt26ygAK AAA=& #13;
can someone tell me what i am missing? thanks.
so what's in the .tmx file as:
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAC+3YsQmAQBAAQb
</data>
now becomes the following HEX string:
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFF
12121212121212121212121212
to do the reverse engineeing, i do the following:
1) convert the HEX string back to byte array
2) do gzip compression using the following method:
public static String gzipCompress(String str) throws IOException
{
if (str == null || str.length() == 0)
{
return str;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes())
gzip.close();
return out.toString("UTF-8");
}
3) do base64 encoding using:
Base64 base = new Base64();
byte[] dataBytes = base.encode(data.getBytes(
but the resulting string looks a little bit different:
H4sIAAAAAAAAAPv/fxQMZyA0at
can someone tell me what i am missing? thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)