我需要将IdCompressZlib组件与CBuilderXE一起使用, 但我没有找到关于该主题的文档或示例。 我也做了一些试验性的尝试,使用它失败了。如何在CBuilderXE中使用IdCompressZlib组件
有人可以发表一些关于如何使用这个组件或一些有用的像这样的话题的例子吗?
更新: Belowe样本代码,我tryed,并给予errore -5时,该方法InflateStream叫做:
int err;
String Fun = "[TestCompress] ", s1, zipString, strTest = "The 'zlib' compression library provides in-memory compression \
and decompression functions, including integrity checks of the uncompressed data. \
This version of the library supports only one compression method (deflation) \
but other algorithms will be added later and will have the same stream interface. ";
TStringStream * inpStream = NULL, *outStream = NULL;
TMemoryStream * stream1 = NULL, *stream2 = NULL;
stream1 = new TMemoryStream();
stream2 = new TMemoryStream();
inpStream = new TStringStream();
outStream = new TStringStream();
inpStream->Clear();
inpStream->WriteString(strTest);
stream1->LoadFromStream(inpStream);
stream1->Position = 0;
IdCompressorZLib1->InflateStream(stream1, stream2);
outStream->Clear();
stream2->SaveToStream(outStream);
zipString = outStream->DataString;
MyLog(Fun + Format("Compress test: Compress size from [%d] to [%d]",
ARRAYOFCONST((strTest.Length(), zipString.Length()))));
究竟是什么,你有麻烦?你迄今为止尝试过哪些方法不适合你?你想用什么'TIdCompressorZLib'呢? –
嗨雷米,我的第一个麻烦是缺乏有关组件的文档,所以一个例子可以给我很多帮助。 我做了一些简单的测试,以压缩流内的字符串。 – enzo2
最后一次尝试是以下情况,当我调用InflateStream方法时,总会出现错误Z_DATA_ERROR(-3)。 – enzo2