public class Packbits
extends java.lang.Object
Contains both unpack and packing method for the Macintosh Packbits compression standard.
Contains Variation for 16 bit RLE packing used in PICT files.
Contains a main() method with some test code for the pack unpack methods.
Constructor and Description |
---|
Packbits() |
Modifier and Type | Method and Description |
---|---|
static int |
getAllRuns(byte[] inb)
Calculate length of every byte run in the input buffer
and store into runb[] buffer.
|
static int |
packbits(byte[] inb,
byte[] outb)
Compress input buffer using RLE packbits compression.
|
static void |
unpackbits(byte[] inb,
byte[] outb)
Decompress an RLE compressed buffer of bytes as per format as
described in source or in a document on TIFF packbits compression.
|
static void |
unpackbits(byte[] inb,
int[] outb)
Variation for 16 bit RLE packing used in PICT files.
|
static void |
unpackbits(byte[] inb,
int ini,
byte[] outb,
int outi,
int len)
More general.
|
static void |
unpackbits(java.io.DataInputStream in,
byte[] outb) |
static void |
unpackbitsLimit(byte[] inb,
int inbLen,
byte[] outb)
Variation for PICT - which provides short inb[] for a give outb[]
This method when it exhausts input byte buffer it clears the remainder
of the output buffer oub.
|
public static void unpackbits(byte[] inb, int ini, byte[] outb, int outi, int len)
inb
- input bufferini
- where compressed data in input buffer startsoutb
- start output indexouti
- where to uncompress data to in output bufferlen
- length of the data after decompression.public static void unpackbitsLimit(byte[] inb, int inbLen, byte[] outb) throws java.lang.ArrayStoreException, java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayStoreException
java.lang.ArrayIndexOutOfBoundsException
public static void unpackbits(byte[] inb, byte[] outb) throws java.lang.ArrayStoreException, java.lang.ArrayIndexOutOfBoundsException
inb
- input buffer with compressed dataoutb
- output buffer for decompressed data
the length of the output buffer must be exact decompressed
lenght of compressed input.java.lang.ArrayStoreException
java.lang.ArrayIndexOutOfBoundsException
public static void unpackbits(byte[] inb, int[] outb) throws java.lang.ArrayStoreException, java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayStoreException
java.lang.ArrayIndexOutOfBoundsException
public static void unpackbits(java.io.DataInputStream in, byte[] outb) throws java.lang.ArrayStoreException, java.lang.ArrayIndexOutOfBoundsException, java.io.IOException
in
- data input stream to read packbits data stream fromoutb
- byte buffer to place unpacked byte data to.
It is assumed that unpackbits is called with outb big enough
for a single sequence of compressed bytesjava.lang.ArrayStoreException
java.lang.ArrayIndexOutOfBoundsException
java.io.IOException
public static int getAllRuns(byte[] inb)
inb
- raw data to calculate byte runs onpublic static int packbits(byte[] inb, byte[] outb) throws java.lang.ArrayStoreException, java.lang.ArrayIndexOutOfBoundsException
inb
- input buffer containing bytes to be compressed
using RLE packbits algorithm. buffer is assumed
to be completely filled.outb
- output buffer containing compressed data.
This must be large enough for worst case compression
of input buffer. [ worst case is 1 additional byte
for every 128 bytes of input buffer with a minimum
size of 2 bytes ]Example Input buffer. 03 04 05 05 06 07 08 Example Stoopid encoding 01 03 04 -01 05 02 06 07 08 Example Proper encoding 06 03 04 05 05 06 07 08
java.lang.ArrayStoreException
java.lang.ArrayIndexOutOfBoundsException