Class LSBBitReader
- java.lang.Object
-
- com.twelvemonkeys.imageio.plugins.webp.LSBBitReader
-
public final class LSBBitReader extends java.lang.ObjectLSBBitReader
-
-
Field Summary
Fields Modifier and Type Field Description private intbitOffsetprivate longbufferPre-buffers up to the next 8 Bytes in input.private javax.imageio.stream.ImageInputStreamimageInputprivate longstreamPosition
-
Constructor Summary
Constructors Constructor Description LSBBitReader(javax.imageio.stream.ImageInputStream imageInput)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longpeekBits(int bits)Reads the specified number of bits from the buffer in an LSB-first way.intreadBit()longreadBits(int bits)Reads the specified number of bits from the stream in an LSB-first way and advances the bitOffset.private longreadBits(int bits, boolean peek)private voidrefillBuffer()private voidresetBuffer()
-
-
-
Method Detail
-
readBits
public long readBits(int bits) throws java.io.IOExceptionReads the specified number of bits from the stream in an LSB-first way and advances the bitOffset. The underlying ImageInputStream will be advanced to the first not (completely) read byte. Requesting more than 64 bits will advance the reader by the correct amount and return the lowest 64 bits of the read number- Parameters:
bits- the number of bits to read- Returns:
- a signed long built from the requested bits (truncated to the low 64 bits)
- Throws:
java.io.IOException- if an I/O error occurs- See Also:
peekBits(int)
-
peekBits
public long peekBits(int bits) throws java.io.IOExceptionReads the specified number of bits from the buffer in an LSB-first way. Does not advance the bitOffset or the underlying input stream. As only 56 bits are buffered (in the worst case) peeking more is not possible without advancing the reader and as such disallowed.- Parameters:
bits- the number of bits to peek (max 56)- Returns:
- a signed long built from the requested bits
- Throws:
java.io.IOException- if an I/O error occurs- See Also:
readBits(int)
-
readBits
private long readBits(int bits, boolean peek) throws java.io.IOException- Throws:
java.io.IOException
-
refillBuffer
private void refillBuffer() throws java.io.IOException- Throws:
java.io.IOException
-
resetBuffer
private void resetBuffer() throws java.io.IOException- Throws:
java.io.IOException
-
readBit
public int readBit() throws java.io.IOException- Throws:
java.io.IOException
-
-