Hi, I'm trying to implement TMX files in Android and I was hoping someone could help. Based on the TMX guide, in order to get the GID's I have to
first base64 decode the string, then gunzip the resulting data if the compression attribute is set to "gzip" as in the above example. Finally, you can read 4 bytes at a time for each GID from the beginning of the data stream until the end.
I think I've figured out the base64 decoding and 'gunzip' but the result from the code below is 27,0,0,0 repeating. I think the output is supposed to be
(0,0) (1,0) (2,0) (3,0) (0,1) (1,1) (2,1) (3,1) (0,2) (1,2) (2,2) (3,2)
Thanks!
public static void main( String[] args )
{
String myString = "H4sIAAAAAAAAAO3NoREAMAgEsLedAfafE4+s6l0jolNJiif18tt/Fj8AAMC9ARtYg28AEAAA";
byte[] decode = Base64.decodeBase64(myString);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(decode);
GZIPInputStream gzipInputStream;
int read;
try
{
gzipInputStream = new GZIPInputStream(byteArrayInputStream);
InputStreamReader inputStreamReader = new InputStreamReader(gzipInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader, 4);
while ( ( read = bufferedReader.read() ) != -1 )
{
System.out.println("read :" + read);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}