1 package eu.svjatoslav.imagesqueeze.codec;
4 * Read individual bits from the input stream.
7 import java.io.IOException;
8 import java.io.InputStream;
10 public class BitInputStream {
14 int currentBytePointer = -1;
16 InputStream inputStream;
18 public BitInputStream(InputStream inputStream){
19 this.inputStream = inputStream;
22 public int readBits(int bitCount) throws IOException {
25 for (int i=0; i < bitCount; i++){
27 readableByte = readableByte << 1;
29 if (currentBytePointer == -1){
30 currentBytePointer = 7;
31 currentByte = inputStream.read();
35 mask = mask << currentBytePointer;
37 int currentBit = currentByte & mask;
40 readableByte = readableByte | 1;
48 public int readIntegerCompressed8() throws IOException{
49 if (readBits(1) == 0){