Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is what manual says:
Syntax:
 
outsize = Huffman_Compress(in,out,insize)
 
outsize Size of output buffer after compression
in Pointer to the input buffer (uncompressed data)
out Pointer to the output buffer (compressed data)
insize Size of input buffer
The output buffer must be able to hold insize × 101
100 + 320 bytes.


But what actually should I do if I have a filename to compress only?

What I have tried:

I have no idea how to start.
I have written a Huffman algorithm by myself and i used string to save data from file and than it was used to algorithm.
I have searched in google some examples how to use BCL but found nothing
Posted
Updated 30-Apr-18 5:21am

1 solution

The function takes a pointer to the input buffer so you have to provide that. So, given the name of a file and the fact that you have to provide a buffer of data, the next step would be to read the file into a buffer of data. What I would do is determine how big the file is, allocate a memory buffer of that size, and then read the file into the buffer. You need to allocate the output buffer also and at that point you will be ready to call the function with all of its arguments. The manual states what the requirements for the output buffer are.
 
Share this answer
 
Comments
Member 13803981 30-Apr-18 20:13pm    
I have a problem with buffers, seems it is ok after compression(but still I have a questions to buffer size, why it should be like in formula above), I just have a file with near 2 times less and some symbols inside. But after decompression output file never equals original - problem is that i need a out buffer size for decompression, but there are no suggestions how large it should be, i tried to manual find the best number but i need to compress any files and size should calculate automaticaly. There is what manual says about decompression:  
in Pointer to the input buffer (compressed data)// char * from file
out Pointer to the output buffer (uncompressed data) // unsigned char *out
insize Size of input buffer //in = GetFileSize(file);
outsize Size of output buffer //???
The output buffer must be able to hold outsize bytes. I can work only wirh text files because i can read only them after this "decompression"
Rick York 1-May-18 1:22am    
Firstly, I think you should post this as a separate question because you limit your reply options otherwise.

Secondly, I can take a wild guess but that is probably not the best option. In some compression libraries there is a function to obtain the size of the uncompressed data. Are you sure BCL does not have one?
Member 13803981 1-May-18 13:09pm    
Thank you for reply. Not I am not sure about it, I will try to understand this library better. In the other hand I want to add size of original file to compressed file and than I will always have size of decompressed file I need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900