Xj3D VRML/X3D Code API

org.web3d.vrml.export.compressors
Class BitPacker

java.lang.Object
  extended byorg.web3d.vrml.export.compressors.BitPacker

public class BitPacker
extends java.lang.Object

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 Summary
BitPacker(int maxLength)
          Construct a bit packer.
 
Method Summary
 void getResult(byte[] result)
          Get the result of the packing.
 void pack(int value, int num_bits)
          Pack this value using num_bits.
 int size()
          Get the size of the result.
 void writeStream(java.io.DataOutputStream dos)
          Write this stream out to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitPacker

public BitPacker(int maxLength)
Construct a bit packer.

Parameters:
maxLength - The maximum length in bytes of the stream to pack.
Method Detail

size

public int size()
Get the size of the result. This will be the number of bytes used, not the maximum length.


getResult

public void getResult(byte[] result)
Get the result of the packing. Use size to preallocate the result array.


pack

public void pack(int value,
                 int num_bits)
Pack this value using num_bits.


writeStream

public void writeStream(java.io.DataOutputStream dos)
                 throws java.io.IOException
Write this stream out to a stream. Only writes the bytes used, not the maximum size.

Throws:
java.io.IOException

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium