Class LSBBitReader

java.lang.Object
com.twelvemonkeys.imageio.plugins.webp.LSBBitReader

public final class LSBBitReader extends Object
LSBBitReader
Author:
Harald Kuhr, Simon Kammermeier
  • Constructor Details

  • Method Details

    • readBits

      public long readBits(int bits) throws IOException
      Reads 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:
      IOException - if an I/O error occurs
      See Also:
    • peekBits

      public long peekBits(int bits) throws IOException
      Reads 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:
      IOException - if an I/O error occurs
      See Also:
    • readBit

      public int readBit() throws IOException
      Throws:
      IOException