如何使用基本压缩库(BCL)进行文件压缩 [英] How to use basic compression library (BCL) for file compression

查看:114
本文介绍了如何使用基本压缩库(BCL)进行文件压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是手册所说的:

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.





但实际应该是什么如果我只有压缩文件名吗?



我尝试过:



我不知道如何开始。

我自己编写了一个霍夫曼算法,我使用字符串来保存文件中的数据,而不是用于算法。

我在谷歌搜索了一些例子如何使用BCL但没有找到任何内容



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

推荐答案

该函数接受一个指向输入缓冲区的指针,因此你必须提供它。因此,给定文件的名称以及必须提供数据缓冲区的事实,下一步是将文件读入数据缓冲区。我要做的是确定文件的大小,分配该大小的内存缓冲区,然后将文件读入缓冲区。您还需要分配输出缓冲区,此时您将准备好使用其所有参数调用该函数。手册说明了输出缓冲区的要求。
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.


这篇关于如何使用基本压缩库(BCL)进行文件压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆