com.twelvemonkeys.io.enc
Class PackBits16Decoder

java.lang.Object
  extended by com.twelvemonkeys.io.enc.PackBits16Decoder
All Implemented Interfaces:
Decoder

public final class PackBits16Decoder
extends Object
implements Decoder

Decoder implementation for 16 bit-chunked Apple PackBits-like run-length encoding.

This version of the decoder decodes chunk of 16 bit, instead of 8 bit. This format is used in certain PICT files.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/enc/PackBits16Decoder.java#2 $
Author:
Harald Kuhr
See Also:
PackBitsDecoder

Constructor Summary
PackBits16Decoder()
          Creates a PackBitsDecoder.
PackBits16Decoder(boolean pDisableNoop)
          Creates a PackBitsDecoder.
 
Method Summary
 int decode(InputStream stream, ByteBuffer buffer)
          Decodes bytes from the given input stream, to the given buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackBits16Decoder

public PackBits16Decoder()
Creates a PackBitsDecoder.


PackBits16Decoder

public PackBits16Decoder(boolean pDisableNoop)
Creates a PackBitsDecoder.

As some implementations of PackBits-like encoders treat -128 as length of a compressed run, instead of a no-op, it's possible to disable no-ops for compatibility. Should be used with caution, even though, most known encoders never write no-ops in the compressed streams.

Parameters:
pDisableNoop - true if -128 should be treated as a compressed run, and not a no-op
Method Detail

decode

public int decode(InputStream stream,
                  ByteBuffer buffer)
           throws IOException
Decodes bytes from the given input stream, to the given buffer.

Specified by:
decode in interface Decoder
Parameters:
stream - the stream to decode from
buffer - a byte array, minimum 128 (or 129 if no-op is disabled) bytes long
Returns:
The number of bytes decoded
Throws:
IOException
DecodeException - if encoded data is corrupt.
EOFException - if a premature end-of-file is encountered.


Copyright © 2015. All Rights Reserved.