我需要將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