Skip to content

Instantly share code, notes, and snippets.

@michaeltandy
Created October 4, 2015 21:48
Show Gist options
  • Save michaeltandy/c051db2243e679e78a37 to your computer and use it in GitHub Desktop.
Save michaeltandy/c051db2243e679e78a37 to your computer and use it in GitHub Desktop.
Inflating hex data (IDAT section from a PNG file)
import java.io.*;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import javax.xml.bind.DatatypeConverter;
public class Inflate {
public static void main(String[] args) throws Exception {
String input = "6881EDC1010D000000C2A0F74F6D0E37A00000000000000000BE0D21000001";
byte[] deflated = DatatypeConverter.parseHexBinary(input);
ByteArrayInputStream bais = new ByteArrayInputStream(deflated);
InflaterInputStream iis = new InflaterInputStream(bais);
byte[] inflated = new byte[256*256];
int size = iis.read(inflated);
System.out.println(size);
System.out.println(DatatypeConverter.printHexBinary(Arrays.copyOf(inflated, size)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment