在Delphi中有很多关于压缩的问题,无论如何这不是重复的.
我在我的应用程序中使用ZipForge来实现zip/unzip功能.
目前我使用ZipForge的2个功能:
1)zip和unzip(!)
2)密码保护档案
现在我从所有档案中删除密码,所以我只需要压缩和解压缩文件.我将它们压缩只是为了在从服务器上传/下载文件时最小化带宽.所以我的想法是处理所有文件一次以解压缩它们(使用密码)并在没有密码的情况下重新压缩它们.
我没有反对ZipForge,无论如何它是一个额外的组件,每次我升级到最新的Delphi版本时我都要等待新的IDE支持,而且组件越多,安装过程中出现的问题就越多(我没有提到成本)因为它非常低,用一些其他东西替换一个组件需要花费时间,所以这不是一个成本问题).
因为我所做的非常简单,我想使用ZLib单元将ZipForge替换为2个简单的函数.我在Torry上找到(并测试过)这里的功能.
您如何看待使用Zlib设备?你看到ZipForge我不会遇到任何潜在的问题吗?你能评论速度吗?
如果使用未压缩的zlib解压缩数据,是否会发生任何事情?
如果它确实改变了数据,那么如何检查数据是否首先压缩为zlib?
char buffer[12] = {"Testing! 12"};
unsigned long compressedSize;
char* compressed = compress(buffer, 12, &compressedSize);
...
char* compress(char* buffer, unsigned long size, unsigned long* compressedSize)
{
Bytef* inBuffer = reinterpret_cast<Bytef*>(buffer);
uLong inSize = static_cast<uLong>(size);
Bytef* outBuffer = 0;
uLong outBufferSize = compressBound(inSize);
int error = compress2(outBuffer, &outBufferSize, inBuffer, inSize, 6);
if(error != Z_OK)
{
switch(error)
{
case Z_MEM_ERROR:
std::cerr << "Memory error!" << std::endl;
break;
case Z_BUF_ERROR:
std::cerr << "Buffer error!" << std::endl;
break;
default:
std::cerr << "Unknown error: " << …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建zpipe.c.我通过configure安装了zlib 1.2.5; 使; make install.我已将zpipe.c文件移动到实际的zlib-1.2.5目录中,其中包含zlib.h头文件.
这是我尝试构建时获得的:
[sk@lldma zlib-1.2.5]$ gcc zpipe.c
/tmp/ccZ2OBz0.o: In function `def':
zpipe.c:(.text+0x3c): undefined reference to `deflateInit_'
zpipe.c:(.text+0x8f): undefined reference to `deflateEnd'
zpipe.c:(.text+0xe2): undefined reference to `deflate'
zpipe.c:(.text+0x163): undefined reference to `deflateEnd'
zpipe.c:(.text+0x1df): undefined reference to `deflateEnd'
/tmp/ccZ2OBz0.o: In function `inf':
zpipe.c:(.text+0x22d): undefined reference to `inflateInit_'
zpipe.c:(.text+0x280): undefined reference to `inflateEnd'
zpipe.c:(.text+0x2c1): undefined reference to `inflate'
zpipe.c:(.text+0x312): undefined reference to `inflateEnd'
zpipe.c:(.text+0x36e): undefined reference to `inflateEnd'
zpipe.c:(.text+0x398): undefined reference to `inflateEnd'
Run Code Online (Sandbox Code Playgroud)
自述文件没有说明在Linux上构建的任何具体内容,我看到deflate.h和其他.h文件都位于目录中......
zpipe.c的源代码如下:http://www.zlib.net/zpipe.c
有任何想法吗?TIA
[sk@lldma zlib-1.2.5]$ …Run Code Online (Sandbox Code Playgroud) 我正在运行Debian 6并且最近安装了PIL.
我预先安装了zlib和jpeg库,它们都在/ usr/lib上
安装时,setup.py文件找到库,我得到标准:
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.3 (default, Jun 29 2012, 22:38:23)
[GCC 4.4.5]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
Run Code Online (Sandbox Code Playgroud)
zlib和jpeg按预期工作.运行selftest.py也会成功
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from ./PIL
--------------------------------------------------------------------
--- PIL CORE support ok
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB …Run Code Online (Sandbox Code Playgroud) 这是错误代码段
/home/jamesblack/Development/v2server/svr_tick.c:1309: undefined reference to `deflateEnd'
Run Code Online (Sandbox Code Playgroud)
当我运行我的makefile时会发生这种情况,看起来它运行此命令.
gcc -O -g -lm -lz -lcrypt -o server .obj/server.o .obj/svr_disk.o .obj/svr_tick.o .obj/svr_act.o .obj/driver.o .obj/svr_god.o .obj/svr_do.o .obj/svr_glob.o .obj/build.o .obj/use_driver.o .obj/look_driver.o .obj/svr_effect.o .obj/driver_etc.o .obj/driver_generic.o .obj/populate.o .obj/helper.o .obj/skill.o .obj/skill_driver.o .obj/talk.o .obj/area.o .obj/path.o .obj/stunrun.o .obj/cityattack.o .obj/npc_malte.o .obj/lab9.o .obj/rdtsc.o .obj/ccp_driver.o
Run Code Online (Sandbox Code Playgroud)
然后它喷出很多类似的错误,我用Google搜索的所有内容都提到安装zlib并将其与-lz链接,这显然是在make命令中,我也很确定我安装正确.apt-get install zlib1g-dev在ubuntu 11 64bit中
有什么想法吗
编辑:
位于/usr/local/zlib/include/zlib.h的我的zlib.h包括这个
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any pending
output. …Run Code Online (Sandbox Code Playgroud) Zlib is supposed to be installed on all mac's by default I'm pretty sure.. But when I run cmake for SFML I get the following errors:
The C compiler identification is Clang 4.1.0
The CXX compiler identification is Clang 4.1.0
Check for working C compiler using: Xcode
Check for working C compiler using: Xcode -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Xcode
Check for working CXX compiler …Run Code Online (Sandbox Code Playgroud) 我有一个zlib链接器错误.花了几个小时尝试解决问题,但到目前为止还没有.Zlib是使用vs2010,win32版本构建的.我的项目使用相同的.
错误提取:
error LNK2019: unresolved external symbol _deflateEnd@4 referenced in function
error LNK2019: unresolved external symbol _deflate@8 referenced in function
error LNK2019: unresolved external symbol _deflateInit_@16 referenced in function
Run Code Online (Sandbox Code Playgroud)
在文件中包含zlib.h,如下所示:
#ifdef WIN32
# define ZLIB_WINAPI
#endif
#include "zlib.h"
Run Code Online (Sandbox Code Playgroud)
项目设置:
链接器 - >常规 - >附加库依赖项:C:\ somepath\zlib
链接器 - >输入 - >附加依赖项:zlibstatic.lib
链接器详细输出(不完整,仅适用于zlib):
Searching C:\somepath\zlib\zlibstatic.lib:
Searching C:\somepath\zlib\zlibstatic.lib:
Run Code Online (Sandbox Code Playgroud)
两个直接命中但它没有做任何事情..
我看到了这个问题,但我不认为我有这个问题,因为:
它实际上是一个开源项目,所以如果有人可以尝试重现问题:
我有一些使用DEFLATE算法压缩的数据,我相信它基本上只是说它的拉链.我正在写一个快速的应用程序,我有兴趣弄清楚是否有解压缩算法的原生纯swift(2.0)实现.
我需要在一个快速的动态框架中实现它,因此,如果我不必使用Objective-c代码,因为这需要我使用swift框架包含的objc框架等,这将是更好的选择.
我想我的问题是,是否存在本机swift实现,或者有没有办法使用swift调用zlib进行本机解压缩?
谢谢
我使用此代码来编码和压缩文本。但是它不能正常工作:
Traceback (most recent call last): File "E:\SOUND.py", line 114, in <module>
unhexsring = str(zlib.decompress(unhexsring).encode('utf8'))
TypeError: a bytes-like object is required, not 'str'
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗?
import zlib,gzip
def str2hex(s):
return binascii.hexlify(bytes(str.encode(s)))
def hex2str(h):
return binascii.unhexlify(h)
hexstring = input()
if len(hexstring) > 200:
hexstring = str(zlib.compress(hexstring.encode('utf-8')))
print(hexstring)
hexstring = str2hex(hexstring)
ph = str(hexstring.decode('utf-8'))
print(ph)
#decompressing text
unhexsring = hex2str(hexstring).decode('utf8')
if 'x' in str(unhexsring):
print('compressed')
unhexsring = str(zlib.decompress(unhexsring).encode('utf8'))
print(unhexsring)
Run Code Online (Sandbox Code Playgroud)
此代码不会解压缩zlib压缩的文本。
因此编码工作良好。
我的麻烦是当我获取编码的字符串并对其进行压缩时,我无法对其进行解压缩。应该如何运作:
1>s = input('some text')
2>if len(s) > 200: s = str(zlib.compress(s.encode('utf-8'))) …Run Code Online (Sandbox Code Playgroud)