zoukankan      html  css  js  c++  java
  • 几种压缩方式:zlib

    zlib:zlib.h http://www.zlib.net/manual.html

    编译时加 -lz

    ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
                                     const Bytef *source, uLong sourceLen));
    

    Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer.

    compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer.

    
    ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
                                      const Bytef *source, uLong sourceLen,
                                      int level));
    

    Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInitsourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer.

    compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the levelparameter is invalid.

    
    ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
    

    compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer.

    
    ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
                                       const Bytef *source, uLong sourceLen));
    

    Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer.

    uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In the case where there is not enough room, uncompress() will fill the output buffer with the uncompressed data up to that point.

  • 相关阅读:
    特征词选择算法对文本分类准确率的影响(前言)
    答火星人.NET。如何使用我的本科毕业程序 正文提取DEMO
    有关matlab画图格式的部分代码
    文本分类中的特征词选择算法系列科普(前言AND 一)
    c++杂项备忘
    写一点应用关于 Lucene.Net,snowball的重新组装(一)在Lucene.Net中加入词性标注与词根还原功能
    C++字符串处理:批量去重,以及大写变小写
    Python打印到文件
    中文分词:采用二元词图以及viterbi算法(三)
    博客园和百度空间,我的两个家
  • 原文地址:https://www.cnblogs.com/yejinru/p/4165709.html
Copyright © 2011-2022 走看看