Compressed file size after deflate

隐身守侯 提交于 2019-12-13 05:57:56

问题


I am using deflate function in zlib library to compress the file. How can I determine the size of the compressed file? Is it the element total_out that indicates the size of compressed file?


回答1:


If you are using deflate() correctly, then you are accumulating or writing the compressed output, and can add up the number of output bytes yourself. At each call, the amount of output is strm.avail_out before the deflate() call minus strm.avail_out after the call. See zpipe.c for an example of the usage of deflate() and inflate().

You can use strm.total_out for the total size of the compressed output if you know that that size will fit in an unsigned long.



来源:https://stackoverflow.com/questions/12840933/compressed-file-size-after-deflate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!