private static void compressed(GravityInputStream in, GSprite out) throws IOException { byte[] storage; Integer i, len, pt; GSpriteImage image; // allocate the sprite image space for storage image = new GSpriteImage(); image.resize(in.nextUShort(), in.nextUShort()); len = in.nextUShort(); // allocate space for storing the bytes of compressed data storage = new byte[len]; // store the compressed pixel data within local storage in.read(storage); // process the pixels from the compressed data into uncompressed data for (i = 0, pt = 0; len > i; i++) { if (storage[i] == 0) { i++; pt += (storage[i] & 0xff); } else { image.setBinaryData(pt++, storage[i]); } } // append this uncompressed image onto the final sprite object out.getFrames().add(image); }