Exemplo n.º 1
0
 private void ReadAlocMap(BitReader bitReader)
 {
     for (int i = 0; i < 256; i++)
     {
         decompressCharFrequency[i] = bitReader.readBit() & 1;
     }
 }
Exemplo n.º 2
0
        private void DecodeAndWrite(BitReader bitReader, int fileLength, TreeNode <KeyValuePair <int, int> > huffmanTree, BitWriter bitWriter)
        {
            TreeNode <KeyValuePair <int, int> > currentNode;

            for (int i = 0; i < fileLength; i++)
            {
                currentNode = huffmanTree;

                while (!currentNode.IsLeaf())
                {
                    int bit = bitReader.readBit();
                    currentNode = bit == 0 ? currentNode.leftChild : currentNode.rightChild;
                }

                //scrie caracterul
                int decodedChar = currentNode.value.Key;
                bitWriter.WriteNBits(decodedChar, 8);
            }
        }