"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Class: CHuffman
Class that implements Huffman compression. Huffman compression uses character frequencies to compress data. Bit codes are assigned to each character, with shorter bitcodes for more common characters, and longer bitcodes for the less common characters.
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the CHuffman class
|
|
InputFileName
|
Property
|
Sets the name of the input file
|
|
OutputFileName
|
Property
|
Sets the name of the output file
|
|
BuildTree
|
Private
|
Builds a Huffman tree based on the character frequency of the input data
|
|
Compress
|
Method
|
Compresses the input file to the output file
|
|
CompressByte
|
Private
|
Compresses a single byte
|
|
Decompress
|
Method
|
Decompresses the input file to the output file.
|
|
Encode
|
Private
|
Huffman encodes a byte
|
|
IntToByte
|
Private
|
This routine does an unsigned conversion from an integer value to a byte value. This correctly handles any integer value.
|
|
LongToInt
|
Private
|
This routine does an unsigned conversion from a long value to an integer value
|
|
ReadFile
|
Private
|
Reads the specified number of bytes from the file.
Using this function significantly increases the speed of processing files. The alternative to using a file buffer is reading a byte at a time from the file.
|
|
Shlb
|
Private
|
Shifts a numeric value left the specified number of bits.
Left shifting can be defined as a multiplication operation. For the number of bits we want to shift a value to the left, we need to raise two to that power, then multiply the result by our original value.
|
|
WriteBit
|
Private
|
Writes to the output file a bit at a time
|
|
WriteFinish
|
Private
|
Flushes any remaining data to the output file
|
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|