private void encodeMatrix(Matrix matrix, SwfEncoder w) { w.writeBit(matrix.hasScale); if (matrix.hasScale) { int nScaleBits = matrix.nScaleBits(); w.writeUBits(nScaleBits, 5); w.writeSBits(matrix.scaleX, nScaleBits); w.writeSBits(matrix.scaleY, nScaleBits); } w.writeBit(matrix.hasRotate); if (matrix.hasRotate) { int nRotateBits = matrix.nRotateBits(); w.writeUBits(nRotateBits, 5); w.writeSBits(matrix.rotateSkew0, nRotateBits); w.writeSBits(matrix.rotateSkew1, nRotateBits); } int nTranslateBits = matrix.nTranslateBits(); w.writeUBits(nTranslateBits, 5); w.writeSBits(matrix.translateX, nTranslateBits); w.writeSBits(matrix.translateY, nTranslateBits); w.flushBits(); }