Class BitPacker
java.lang.Object
org.web3d.vrml.export.compressors.BitPacker
Pack a stream of integers of variables bits into a packed form.
Loosely copied from Johnathon Blow's "Packing Integers" article.
- Version:
- $Revision: 1.4 $
- Author:
- Alan Hudson
-
Constructor Details
-
BitPacker
public BitPacker(int maxLength) Construct a bit packer.- Parameters:
maxLength
- The maximum length in bytes of the stream to pack.
-
-
Method Details
-
size
public int size()Get the size of the result. This will be the number of bytes used, not the maximum length.- Returns:
-
getResult
public void getResult(byte[] result) Get the result of the packing. Use size to preallocate the result array.- Parameters:
result
-
-
pack
public void pack(int value, int num_bits) Pack this value using num_bits.- Parameters:
value
-num_bits
-
-
writeStream
Write this stream out to a stream. Only writes the bytes used, not the maximum size.- Parameters:
dos
-- Throws:
IOException
-