X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=imagesqueeze.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fimagesqueeze%2Fcodec%2FBitOutputStream.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fimagesqueeze%2Fcodec%2FBitOutputStream.java;h=0000000000000000000000000000000000000000;hp=469bb7be0731cbe8c84b2a59567230ef2b359554;hb=4bcffe8896c08c9f60b2707da71bb39a64618d93;hpb=c7d0b8e1723045c0df086d9214a35f54db47684c diff --git a/src/main/java/eu/svjatoslav/imagesqueeze/codec/BitOutputStream.java b/src/main/java/eu/svjatoslav/imagesqueeze/codec/BitOutputStream.java deleted file mode 100755 index 469bb7b..0000000 --- a/src/main/java/eu/svjatoslav/imagesqueeze/codec/BitOutputStream.java +++ /dev/null @@ -1,63 +0,0 @@ -package eu.svjatoslav.imagesqueeze.codec; - -/** - * Write individual bits to the output stream. - */ - -import java.io.IOException; -import java.io.OutputStream; - -public class BitOutputStream { - - int currentByte; - int currentBytePointer; - - OutputStream outputStream; - - public BitOutputStream(OutputStream outputStream){ - currentByte = 0; - currentBytePointer = 0; - this.outputStream = outputStream; - }; - - - public void storeBits(int data, int bitCount) throws IOException { - for (int i=bitCount-1; i >= 0; i--){ - - int mask = 1; - mask = mask << i; - - int currentBit = data & mask; - currentByte = currentByte << 1; - - if (currentBit != 0){ - currentByte = currentByte | 1; - } - currentBytePointer++; - - if (currentBytePointer == 8){ - currentBytePointer = 0; - outputStream.write(currentByte); - currentByte = 0; - } - } - } - - public void storeIntegerCompressed8(int data) throws IOException{ - if (data < 256){ - storeBits(0, 1); - storeBits(data, 8); - } else { - storeBits(1, 1); - storeBits(data, 32); - } - } - - public void finishByte() throws IOException { - if (currentBytePointer != 0){ - outputStream.write(currentByte); - currentBytePointer = 0; - } - } - -}